Clerobee - a featureful UID generator
========
clerobee is a very handy utility library allowing to generate UIDs considering actual time, network resources and process in a distributed environment.
Use cases
Following use cases are supported:
-
Normal UIDs:
Identifiers for general usage with length between 4 and 256. Can be used as cryptographic keys, user IDs, session keys, etc.
-
Derived UIDs:
To express ownership-like relations between identifiers.
If you have to identify devices and be able to link them to a user with verify the ownership against the userID, then simply generate a UID for the user and generate derived UIDs for the devices.
Therethrough the ownership of the device where for example a REST request is coming, can be verified.
-
Sourced UIDs:
Using a JS object data as source for the generation process.
For example to generate product/license keys based on user information and to check if they can be matched while a possible registration process later on.
Usage
var Cerobee = require('clerobee');
var cerobee = new Cerobee( 128 );
...
var nID = cerobee.generate();
var nID_2 = cerobee.generate( 16 );
...
var sID = cerobee.generate( nID );
var test_1 = cerobee.isDerived( nID, sID );
...
var customer = { email:'test@provider.org' };
var pID = cerobee.generate( customer, 128 );
var test_2 = cerobee.isSourced( reference, 128, pID );
And that's it!
License
MIT
Changelog
- 0.0.1: Initial release...