Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

URL and cookie safe UIDs

License

NotificationsYou must be signed in to change notification settings

crypto-utils/uid-safe

Repository files navigation

NPM VersionNPM DownloadsNode.js VersionBuild StatusTest Coverage

URL and cookie safe UIDs

Create cryptographically secure UIDs safe for both cookie and URL usage.This is in contrast to modules such asuid2whose UIDs are actually skewed due to the use of% and unnecessarilytruncate the UID. Use this if you could still use UIDs with- and_ inthem.

Installation

$ npm install uid-safe

API

varuid=require('uid-safe')

uid(byteLength, callback)

Asynchronously create a UID with a specific byte length. Becausebase64encoding 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)throwerr// do something with the string})

uid(byteLength)

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

Note: To use promises in Node.jsprior to 0.12, promises must be"polyfilled" usingglobal.Promise = require('bluebird').

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

uid.sync(byteLength)

A synchronous version of above.

varstring=uid.sync(18)

License

MIT


[8]ページ先頭

©2009-2025 Movatter.jp