Home > front end >  Js on aes encryption, Java back-end decryption
Js on aes encryption, Java back-end decryption

Time:11-28

I now js for aes encryption, Java encryption is no problem, but the js front-end aes encryption, Java back-end aes decryption failure
After screening, Java back-end is key to adopt the following steps:
KeyGenerator. Init (128, new SecureRandom ( keyBytes ));
SecretKey sk=keyGenerator. GenerateKey ();
SecretKeySpec SecretKeySpec=new SecretKeySpec (sk) getEncoded (), "the AES) conversion;
The front-end js. The key is to use the key=CryptoJS enc. Utf8, parse (" XXXXXXXXXXXXXXXX ");//16
Such Java back-end if direct use SecretKeySpec SecretKeySpec=new SecretKeySpec ( keyBytes , "AES) can decrypt, but now cannot be modified after the end, so I want to ask next js front-end have corresponding keyGenerator. GenerateKey (); Method, not unable to decrypt by then end,

CodePudding user response:

The building Lord, I set of back-end encryption to decrypt the front-end, decryption failure, do not know what reason

CodePudding user response:

reference 1st floor weixin_48351020 response:
the building Lord, I set of back-end encryption to decrypt the front-end, decryption failure, do not know what reason
fill is not the same, need to introduce aes - js,

CodePudding user response:

Be consistent in initial vector, filling way
  • Related