修改 web-server 加密算法用以支持原生客户端
This commit is contained in:
@@ -24,8 +24,8 @@ function aesDecrypt(data, key, iv) {
|
||||
|
||||
function privateDecrypt(encryptMsg) {
|
||||
const decryptMsg = crypto.privateDecrypt(
|
||||
privateKey,
|
||||
encryptMsg
|
||||
{ key: privateKey, padding: crypto.constants.RSA_PKCS1_PADDING },
|
||||
encryptMsg
|
||||
);
|
||||
return decryptMsg;
|
||||
}
|
||||
@@ -43,8 +43,8 @@ module.exports = options => {
|
||||
|
||||
|
||||
const reqHeader = ctx.request.header;
|
||||
const aesKey = reqHeader['k'] ? privateDecrypt(Buffer.from(reqHeader['k'], 'base64')) : ENCRYPT_KEY;
|
||||
const aesIV = reqHeader['v'] ? privateDecrypt(Buffer.from(reqHeader['v'], 'base64')) : ENCRYPT_IV;
|
||||
const aesKey = reqHeader['k'] ? privateDecrypt(new Buffer(reqHeader['k'], 'base64')) : ENCRYPT_KEY;
|
||||
const aesIV = reqHeader['v'] ? privateDecrypt(new Buffer(reqHeader['v'], 'base64')) : ENCRYPT_IV;
|
||||
|
||||
if (isJSON(reqBody)) {
|
||||
const encodeStr = aesEncrypt(JSON.stringify(reqBody), aesKey, aesIV);
|
||||
|
||||
Reference in New Issue
Block a user