1. uid-safe
URL and cookie safe UIDs
uid-safe
Package: uid-safe
Created by: crypto-utils
Last modified: Tue, 28 Jun 2022 03:28:38 GMT
Version: 2.1.5
License: MIT
Downloads: 11,381,397
Repository: https://github.com/crypto-utils/uid-safe

Install

npm install uid-safe
yarn add uid-safe

uid-safe

NPM Version
NPM Downloads
Node.js Version
Build Status
Test Coverage

URL and cookie safe UIDs

Create cryptographically secure UIDs safe for both cookie and URL usage.
This is in contrast to modules such as rand-token
and uid2 whose UIDs are actually skewed
due to the use of % and unnecessarily truncate the UID.
Use this if you could still use UIDs with - and _ in them.

Installation

 $ npm install uid-safe

API

 var uid = require('uid-safe')

uid(byteLength, callback)

Asynchronously create a UID with a specific byte length. Because base64
encoding is used underneath, this is not the string length. For example,
to create a UID of length 24, you want a byte length of 18.

 uid(18, function (err, string) {
  if (err) throw err
  // do something with the string
})

uid(byteLength)

Asynchronously create a UID with a specific byte length and return a
Promise.

Note: To use promises in Node.js prior to 0.12, promises must be
"polyfilled" using global.Promise = require('bluebird').

 uid(18).then(function (string) {
  // do something with the string
})

uid.sync(byteLength)

A synchronous version of above.

 var string = uid.sync(18)

License

MIT

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code