I want to decrypt an encrypted cipher like 4vEUkMYlT2qJq+9J0GT8VQ== using Rijndael 128 ecb algorithm. I found some library but nothing work correctly. some of libraries only work with nodejs others work with php. I have only a simple html page that get an encrypt text from an ajax.and I want to decrypt using same algorithm Rijndael 128 ecb. (encrypt text is 4vEUkMYlT2qJq+9J0GT8VQ== decrypted result is Novaphen) can every one give me a solution to decrypt with javascript?
finally I can do it with this link. : Encrypt with PHP, Decrypt with Javascript Here is my Decryption function :
function DecryptData(encryptedData) {
var decryptedText = null;
try {
// Mcrypt pads a short key with zero bytes
key = CryptoJS.enc.Utf8.parse('doctorlinktechno')
iv = CryptoJS.enc.Utf8.parse('keee')
// Keep the ciphertext in Base64 form
ciphertext = '4vEUkMYlT2qJq+9J0GT8VQ=='
// Mcrypt uses ZERO padding
plaintext = CryptoJS.AES.decrypt(ciphertext, key, { iv: iv, mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.ZeroPadding })
// I ran this in nodejs
return CryptoJS.enc.Utf8.stringify(plaintext);
}
//Malformed UTF Data due to incorrect password
catch (err) {
return "";
}
}
the point is you must to include dependent files base on your work. for example I want to use ecb mode and padding zero and I included following files:
<script src="scripts/aes/core.js"></script>
<script src="scripts/aes/enc-base64.js"></script>
<script src="scripts/aes/cipher-core.js"></script>
<script src="scripts/aes/aes.js"></script>
<script src="scripts/aes/mode-ecb.js"></script>
<script src="scripts/aes/pad-zeropadding.js"></script>