README
non-blocking-bcrypt-nodejs
warper for bcrypt-nodejs that works on a sub process to keep the crypto actions from starving the event loop.Limitations
works on NodeJS version 7.6+,Installing
npm install non-blocking-bcrypt-nodejs --save
lets jump to some examples
Examples
genSalt
rounds
- [OPTIONAL] - the number of rounds to process the data for. (default - 10)
const bcrypt = require('non-blocking-bcrypt-nodejs')
(async () =>{
try {
const {salt} = await bcrypt.genSalt()
}
catch(err){
}
})();
genHah
data
- [REQUIRED] - the data to be encrypted.salt
- [REQUIRED] - the salt to be used in encryption.
const bcrypt = require('non-blocking-bcrypt-nodejs')
(async () =>{
try {
const {salt} = await nonBlockingBcrypt.genSalt();
const {hash} = await nonBlockingBcrypt.genHash(salt, 'sdsasdsafasf');
}
catch(err){
}
})();
saltAndHash
data
- [REQUIRED] - the data to be encrypted.
const bcrypt = require('non-blocking-bcrypt-nodejs')
(async () =>{
try {
const {hash} = await nonBlockingBcrypt.saltAndHash( 'sdsasdsafasf');
}
catch(err){
}
})();
compare
data
- [REQUIRED] - data to compare.encrypted
- [REQUIRED] - data to be compared to.
const bcrypt = require('non-blocking-bcrypt-nodejs')
(async () =>{
try {
const {salt} = await nonBlockingBcrypt.genSalt();
const {hash} = await nonBlockingBcrypt.genHash(salt, 'sdsasdsafasf');
const match = await nonBlockingBcrypt.compare('sdsasdsafasf', hash);
}
catch(err){
}
})();
Tests
npm test