Authored by 王水玲

uid cookie 加密解密

/**
* 登录注册密码加密
* 登录注册密码加密,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
};
... ...
... ... @@ -76,9 +76,10 @@ const Auth = {
return Auth.profile(uid).then((userInfo) => {
let token = sign.makeToken(uid);
let data = userInfo.data;
let encryptionUid = aes.encryptionUid(data.uid);
if (data) {
let uidCookie = `{data.profile_name}::${data.uid}::${data.vip_info.title}::${token}`;
let uidCookie = `{data.profile_name}::${encryptionUid}::${data.vip_info.title}::${token}`;
req.session._TOKEN = token;
req.session._LOGIN_UID = uid;
... ...
... ... @@ -59,7 +59,7 @@
"uuid": "^2.0.2",
"winston": "^2.2.0",
"winston-daily-rotate-file": "^1.1.4",
"yoho-node-lib": "0.0.21"
"yoho-node-lib": "0.0.22"
},
"devDependencies": {
"autoprefixer": "^6.3.6",
... ...