You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to encrypt some data on client side and Decrypt it on the server side
but it is giving error on the server side saying that "Incorrect key".
Followings are my code snippets
var key = "randomKey";
var hash = CryptoJS.MD5(key);
var hashedKey = btoa(hash.toString(CryptoJS.enc.Base64));
var iv = "1234567812345678";
var message = "#This is the plain text to encrypt#";
var encrypted = CryptoJS.AES.encrypt(message, hashedKey, {iv : iv, mode: CryptoJS.mode.CBC,padding: CryptoJS.pad.Pkcs7} );
var encrypteData=encrypted.toString(CryptoJS.enc.utf8);
That's how I am encrypting at client side. and sending "iv", "hashedKey" and
"encryptedData" to server side.
we are decrypting this encrypted data at server side using java. we are using
AES/CBC/PKCS5Pading. By passing iv, key and encrypted message to the "doFinal"
method but we are getting error message as "Given final block not padded
properly"
Cipher decrypt = Cipher.getInstance("AES/CBC/PKCS5Padding");
decrypt.init(Cipher.DECRYPT_MODE, hashedKey,iv);
byte[] decryptedMsg = decrypt.doFinal(encryptedMsg);
What am i doing wrong?
Original issue reported on code.google.com by tiwari.a...@gmail.com on 14 Aug 2014 at 9:43
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
tiwari.a...@gmail.com
on 14 Aug 2014 at 9:43The text was updated successfully, but these errors were encountered: