GithubHelp home page GithubHelp logo

uid-safe's Introduction

UID Safe

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.

API

var uid = require('uid-safe')

uid(byteLength, [cb])

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!

If cb is not defined, a promise is returned. However, to use promises, you must either install bluebird or use a version of node.js that has native promises, otherwise your process will crash and die.

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

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

uid.sync(byteLength)

A synchronous version of above.

var string = uid.sync(18)

uid-safe's People

Contributors

jonathanong avatar

Watchers

Jérémy Lal avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.