블로그 이미지
흰색앵초

calendar

1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

Notice

2017. 3. 31. 16:27 프로그래밍/NodeJS
※ crpyto는 nodejs에 포함되어 있는 모듈이므로 따로 설치하실 필요가 없습니다. 그냥 사용하시면 됩니다


아래와 같이 사용하시면 되겠습니다.

var crypto = require('crypto');

/**
 * hash password with sha512.
 * @function
 * @param {string} password - List of required fields.
 * @param {string} salt - Data to be validated.
 */
var sha512 = function(password, salt){
    var hash = crypto.createHmac('sha512', salt); /** Hashing algorithm sha512 */
    hash.update(password);
    var value = hash.digest('hex');
    return {
        salt:salt,
        passwordHash:value
    };
};



출처 : https://ciphertrick.com/2016/01/18/salt-hash-passwords-using-nodejs-crypto/

posted by 흰색앵초