aes-pwd.js 613 Bytes
/**
 * 登录注册密码加密
 * @author: wsl<shuiling.wang@yoho.cn>
 * @date: 2016/07/07
 */

'use strict';

const crypto = require('crypto');

const aesPwd = (pwd) => {
    let algorithm = 'aes-128-ecb';
    let key = 'yoho9646yoho9646';
    let clearEncoding = 'utf8';
    let cipherEncoding = 'base64';
    let iv = '';
    let cipher = crypto.createCipheriv(algorithm, key, iv);
    let cipherChunks = [];

    cipherChunks.push(cipher.update(pwd, clearEncoding, cipherEncoding));
    cipherChunks.push(cipher.final(cipherEncoding));

    return cipherChunks.join('');
};

module.exports = {
    aesPwd
};