I am trying to convert a AES Encryption function from JavaScript CryptoJS into PHP script for scrapping a website login with PHP.
/**
data.v1 is 8 bit dynamic string like '7B34F0C6' from the server
and data.v2 is 16 bit dynamic string like '7lGmxLNfmQ85vfl3' from the server
*/
var password = $('input#password').val();
var passwordMd5 = CryptoJS.MD5(password);
var passwordKey = CryptoJS.SHA256(CryptoJS.SHA256(passwordMd5 + data.v1) + data.v2);
var encryptedPassword = CryptoJS.AES.encrypt(passwordMd5, passwordKey, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.NoPadding});
encryptedPassword = CryptoJS.enc.Base64.parse(encryptedPassword.toString()).toString(CryptoJS.enc.Hex);
I need to get this encryptedPassword with PHP.
I've looked a library mentioned on this question Encrypt with PHP, Decrypt with Javascript (cryptojs) but there is a difference with mode ECB and CBC. could you help me explain this code and what is the equivalent with PHP or which library i should use to convert this javacript code to PHP ?