Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 585 Bytes

File metadata and controls

42 lines (28 loc) · 585 Bytes

bcrypt

use node.bcrypt.js

install

npm install --save bcrypt

import

var bcrypt = require('bcrypt');

encrypt

var beforeHash = 'Hello World';

bcrypt.genSalt(10, function(err, salt) {
    bcrypt.hash(beforeHash, salt, function(err, hashed) {
        // Store hash in your password DB.
    });
});

decrypt

can't decrypt

verify

var beforeHash = 'Hello World';

bcrypt.compare(beforeHash, hashed, function(err, res) {

    // res : true or false
});