-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Pkcs5 #334
Comments
This was referenced Jan 24, 2021
This is how I do it: const bytes = crypto.AES.decrypt(
dataStr,
crypto.enc.Utf8.parse(realAESKey),
{
mode: crypto.mode.CBC,
padding: crypto.pad.Pkcs7,
iv: crypto.enc.Utf8.parse(realAESIV),
},
);
const decryptedStr = crypto.enc.Utf8.stringify(bytes);
return decryptedStr.toString(); And encrypt: const key = generateRandomStr(32);
const text = JSON.stringify(content);
const encryptKey = crypto.enc.Utf8.parse(key);
const iv = generateRandomStr(16);
const encryptedStr = crypto.AES.encrypt(
crypto.enc.Utf8.parse(text),
encryptKey,
{
mode: crypto.mode.CBC,
padding: crypto.pad.Pkcs7,
iv: crypto.enc.Utf8.parse(iv),
},
); And Java side can use Pkcs5 to inter-op with the result from JS. |
Note that Java side may first use Base64 decode before decrypt dataString, but in JS we don't need to do so. |
Thanks @linonetwo. You save my day. |
好像和本来写法差不多,这样后端如果是pkcs5也能解出来吗 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems it supports pkcs5, but only pkcs7 is available now...
Can you support 5?
crypto-js/src/cipher-core.js
Line 369 in 90884e6
This is very confusing that you didn't export the pkcs5, but If user search through issues, he will found this finally:
The text was updated successfully, but these errors were encountered: