decryption at client side with javascript?

998 views Asked by At

I am getting an encrypted text on the client side which has been encrypted at server(with java) using AES-256 bit , and SHA-256 (2048 bit), i have no idea how to decrypt it. (provided that i am having a key at the client side which has been used at server side for the encryption purpose and i am using symmetric key cryptography).

i am using SJCL for this and have tried this code

decodedData = sjcl.decrypt(key,encryptedData);

but it is giving the error

"json decode: this isn't json! "

if you can suggest any other library(along with the code will be better).

any help will be greatly appreciated.

EDIT-

yes i was using the SHA-256 as key for AES-256, but going further i will not use SHA-256 so now i need the answer only for how to decrypt the data which has been Encrypted with AES-256 .

EDIT-

i tried it with pidcrypt since the data which i was trying to decrypt was encrypted using cbc mode that sjcl doesn't have but picrypt, i tried the following code

var data = "IFoRnqsmfPN9qKXu+oIKTIZxj1nRyVKP0FjGqefBZ8BMZ0ocBv9Hhfg560lM+CZhg00Yk29bn+/U5kOYNV9nSeTwdJTeXFX2H+m7ttE++1cJ7fjeYEiJv1JMvFRWm/PTZbmcmy+0pgXzuCzF0R3AEmEIuD+tpOX/Knc1FODIRNYb2yxKNW2iNRVKq9g/Qyuqn6w5Bp1cfdnTHNcNZL+GMHKoimKswgxPsR6NfbR/BMs";

var key  = "fdgfg787kim9om89";

var aes = new pidCrypt.AES.CBC();
var decryptedData = aes.decryptText(crypted, key);

but it is returning null(no error), any guess what is wrong with this?

0

There are 0 answers