Jen is a portable and safe Javascript password/number generator
Jen allows to generate passwords, random bytes and random numbers securely using cryptographic approach.
Jen supports 4 engines to generate random bytes :
- NodeJS Crypto API
- W3C Crypto API http://www.w3.org/TR/WebCryptoAPI/
- Microsoft Crypto API https://msdn.microsoft.com/en-us/library/windows/desktop/aa380256(v=vs.85).aspx
- Failsafe
Failsafe uses Math.random() which is not safe because the random number generator doesn't use a cryptographic approach.
- You can see a demo at http://mykiimike.github.io/jen/
- Explaination Cross Domain Math.random() prediction
Hardened passwords
Jen has a hardened passwords generator activated by default which adds specials chars into the password. For those who want to use Jen for others things they must set to false the hardened argument at the constructor.
Install
On NodeJS
npm install node-jen
On browser
With browserify & Webpack
Just include / require this repo or jen.js direcly into your code.
Library
Jen(hardened, banFailsafe)
var hdl = true true;
- hardened: Use hardened version includes specials chars into password generator: (default true)
- banFailsafe: Generate an alert when using Failsafe cryptography (default true)
Jen.password(min, max, regex)
Jen.password(min, max)
Jen.password(min)
This function returns a random String.
- min: Minimum String length (must be upper to 4)
- max: Maximum String length
- regex: Regular expression to filter selected chars
console;forvar a=0; a<10; a++ console; console;forvar a=0; a<10; a++ console; console;hdl;forvar a=0; a<10; a++ console; console;forvar a=0; a<10; a++ console; console;hdl;forvar a=0; a<10; a++ console;
Jen.random(size)
Generate random numbers (integers) into a String.
- size: Size of bytes read from randomBytes
console;forvar a=0; a<10; a++ console;
Jen.randomBytes(size)
Generate random bytes into an Uint8Array.
- size: Size of bytes read from randomBytes
console;forvar a=0; a<10; a++ console;
Jen.randomBetween(max, min)
Generate random number between the given min and max arguments
- max: Maximum value
- min: Minimum value
console;forvar a=0; a<10; a++ console;
Jen.hardening(bool)
Set on/off hardening string generator
- bool: boolean to activate hardened password generator (default true)
Jen.engine()
Returns the current engine in a String
console;
Jen.stats()
Get password generation statistics
console;
Jen.fill()
This function fill the random buffer line. You don't need to use it.
Contact
- Michael Vergoz
- @mykiimike / Github