here is solution :
// Include the CryptoJS and Base64 JS.
var encrypted = '{{ $encrypted }}';
var key = "{{ $key }}";
var encrypted_json = JSON.parse(Base64.decode(encrypted));
/*
This looks like this:
{
"iv":"LjF1hMU/z9TYX14BTKHO+g==",
"value":"A2r3MRwTzS67Id4/TmXZKG71vGF1prjQ8oaGrThjKw4=",
"mac":"6762445e827e2e4acff56ee600b250efe48c71aa75ac65bd50fd42e1e59e671c"
}
*/
// Now I try to decrypt it.
var decrypted = CryptoJS.AES.decrypt(encrypted_json.value, CryptoJS.enc.Base64.parse(key), {
iv : CryptoJS.enc.Base64.parse(encrypted_json.iv)
});
console.log(decrypted.toString(CryptoJS.enc.Utf8));
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community