@inanna/pw
v1.4.0
Published
password engine
Downloads
2
Readme
Usage
import {PBKDF2, PW} from '@inanna/pw'
// or import {Scrypt, PW} from '@inanna/pw'
// Create KDF
const kdf = new PBKDF2({pwlen: 6});
// Create and encrypt password
const pw = await kdf.pw('123456');
// Check password
console.log(await pw.check('123456')); // return true
console.log(await pw.check('foo')); // return false
// Export password
const jsonPW = JSON.stringify(pw);
// Import password
const pw2 = PW.from(jsonPW)
// Import null-password
const nopw = PW.from(null);
console.log(await nopw.check('any password')); // return false
console.log(JSON.stringify(nopw)); // return 'null'
Contents
[functions]
- [genSalt(length)]
- [scrypt(password, salt, keylen, options)]
- [pbkdf2(password, salt, iterations, keylen, digest)]
[KDF]
- [kdf.keylen]
- [kdf.saltlen]
- [kdf.pwlen]
- [kdf.genSalt()]
- [kdf.toJSON()]
- [kdf.toBSON()]
- [kdf.validate(password)]
- [kdf.pw(password)]
[PW]
- [PW.from(value)]
- [pw.type]
- [pw.key]
- [pw.salt]
- [pw.time]
- [pw.toJSON()]
- [pw.toBSON()]
- [pw.test(password)]
- [pw.check(password)]
[Scrypt]
- [new Scrypt({keylen, saltlen, pwlen, options})]
- [scrypt.options]
[PBKDF2]
- [PBKDF2.isDigest(digest)]
- [new PBKDF2({keylen, saltlen, pwlen, digest, iterations})]
- [pbkdf2.digest]
- [pbkdf2.iterations]
[ScryptPW]
- [scryptPW.options]
[PBKDF2PW]
- [pbkdf2PW.digest]
- [pbkdf2PW.iterations]