Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

写AES解密脚本报错。。 #14

Open
DF2L opened this issue Jul 30, 2020 · 2 comments
Open

写AES解密脚本报错。。 #14

DF2L opened this issue Jul 30, 2020 · 2 comments

Comments

@DF2L
Copy link

DF2L commented Jul 30, 2020

密文是原始的base64形式的,js里面不知道哪一步urldecode了一下,把那种有+号的��码成空格了,导致解密失败,我应该改哪个地方- -。

@c0ny1
Copy link
Owner

c0ny1 commented Jul 31, 2020

请展示demo代码

@DF2L
Copy link
Author

DF2L commented Jul 31, 2020

感谢回复!

/**************************************************************************/
var wasSuccessful = phantom.injectJs('../crypto-js-4.0.0/crypto-js.js');

// 加密函数
function js_encrypt(payload){
var key = CryptoJS.enc.Utf8.parse("1234123412ABC!@#");
var newpayload = CryptoJS.AES.encrypt(payload, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return newpayload.toString();
}

// 解密函数
function js_decrypt(payload){
//1234445 IT+0ugGnzZ/I788YwiY/lA==
//1234777 5zjZV2m6VfMu4PjtmNyKIA==
var key = CryptoJS.enc.Utf8.parse("1234123412ABC!@#");
var newpayload = CryptoJS.AES.decrypt(payload, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return newpayload.toString(CryptoJS.enc.Utf8);;
}
/**************************************************************************/

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants