|
|
/**
|
|
|
* 登录注册密码加密
|
|
|
* 登录注册密码加密,uid加密
|
|
|
* @author: wsl<shuiling.wang@yoho.cn>
|
|
|
* @date: 2016/07/07
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
const crypto = require('crypto');
|
|
|
const crypto = global.yoho.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 crypto.encryption('yoho9646yoho9646', pwd);
|
|
|
};
|
|
|
|
|
|
return cipherChunks.join('');
|
|
|
/**
|
|
|
* uid加密
|
|
|
**/
|
|
|
const encryptionUid = (uid) => {
|
|
|
return crypto.encryption('yoho9646abcdefgh', uid + '');
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
aesPwd
|
|
|
aesPwd,
|
|
|
encryptionUid
|
|
|
}; |
...
|
...
|
|