2.0.0 • Published 8 years ago
bentojs-api-password v2.0.0
Password
Installation
$ npm install --save bentojs-api-password
If you are not using the default crypto pbkdf2 adapter, be sure to also download the package related to the encryption you wish to use.
# bcrypt
$ npm install --save bcryptjs
Adapters & Arguments
By default the optional adapter and args arguments falls back on the settings defined in your password configuration. In most cases the default configuration is what most Bento.js modules will be utilizing as custom requirements are unknown and goes against Bento.js modular approach. The options are open for uses cases in private project based code.
Hash
const password = bento.provider('password');
const hash = yield password.hash(password, [adapter], [args]);
Compare
const password = bento.provider('password');
const isValid = yield password.compare(password, hash, [adapter], [args]);
Configurations
Each approach requires their own configurations set up properly to work.
PBKDF2
password : {
adapter : 'pbkdf2',
args : [
'salt', // salt
10000, // iterations
512, // keylen
'sha512' // digest
]
}
BCrypt
password : {
adapter : 'pbkdf2',
args : [ 10 ] // salt
}
2.0.0
8 years ago