non-blocking-bcrypt-nodejs

1.0.4 • Public • Published

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

Package Sidebar

Install

npm i non-blocking-bcrypt-nodejs

Weekly Downloads

2

Version

1.0.4

License

MIT

Unpacked Size

12.6 kB

Total Files

6

Last publish

Collaborators

  • amit21