token-boy
Serves a token of given bit length with given encoding, digested by default.
Collision detection logic is left out as it should be specific to your application.
Install
node
For npm install token-boy --save
For browsers
bower install token-boy
or
git clone git@github.com:zeusdeux/token-boy.git
If you plan to use it with browserify, then just require
index.js
.
If you plan to use it directly in the browser, then include browser/token-boy.min.js
. This will export
a global require
function.
You can then do:
Usage
Simple usage
var tokenBoy = var token = token //returns a 128 bit, base64 encoded, digested token
Advanced usage
var tokenBoy = 'hex' //specifying default encoding to be hexvar token token = token //returns a 128 bit, hex encoded, digested tokentoken = token //returns a 256 bit, base64 encoded, digested tokentoken = token //returns a 128 bit, base64 encoded, non-digested tokentoken = token //returns a 512 bit, ascii encoded, non-digested token //note://both of these return a 512 bit, default encoding ('hex' in this case) encoded, digested token//this is because ascii is not a valid digest encoding type as of node v0.10.29token = tokentoken = token
As of Node v0.10.29
Encodings supported are:
ascii
utf8
utf16le
ucs2
base64
binary
hex
Default encodings supported are:
binary
base64
hex
The default encodings supported are only a subset of encodings as the digest()
method documentation asks us to only
use these. If it is needed, I shall add support for all encodings to be used as default encodings but I don't see
the need for it right now.
Changelog
- 0.0.4
- bugfixes and documentation fixes
- fixed the broken
0.0.3
version
- 0.0.3 (do not use this version)
- bugfixes