javascript - How to decrypt from encrypted data in JS to PHP?
Get the solution ↓↓↓Hard to explain, I'll just show you my code. (copied) In JS: (I used Cryptojs)
var key = "01234567890123456789012345678901";
var iv = "1234567890123412";
function encrypt(data){
var data = CryptoJS.AES.encrypt(data, key, iv);
return data;
}
function decrypt(data){
var code = CryptoJS.AES.decrypt(data,key);
var decryptedData = code.toString(CryptoJS.enc.Utf8);
return decryptedData;
}
In PHP (Codeigniter): -assuming I've passed the encrypted data to php from js.
$username = $this->input->post('username');
$encrypt_method = "AES-256-CBC";
$key = '01234567890123456789012345678901';
$iv = "1234567890123412";
$decrypted = openssl_decrypt($username, $encrypt_method, $secret_key, OPENSSL_RAW_DATA, $iv);
echo $decrypted; //gives null or empty result
anyone please tell me what I'm doing wrong here?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: use the option --with-all-dependencies (-w) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.