I have a text file that was encrypted by cryptojs(and maybe some custom js function to iterate the hash of the password) and I want to decrypt it in windows via openssl.exe not with a browser(which works flawlessly when i provide it with password). it looks like cryptojs has used some custom stuff like deriving key with sha512 and iterating it 11512 times as you see the js decryptor below and then uses evpkdf iteration 484 times(i have no idea what this stuff mean). the code snippet for decrypting the file from the cryptojs is below, i need the openssl exe -cli params to do so without using that js library in a browser.
function hex2a(t) { //hex to ascii
for (var e = t.toString(), i = "", n = 0; n < e.length && "00" !== e.substr(n, 2); n += 2) i += String.fromCharCode(parseInt(e.substr(n, 2), 16));
return i; }
function decoder(secret, passwrd) {
for (var i = CryptoJS.SHA512(passwrd), n = 0; n < 11512; n++)
i = CryptoJS.SHA512(i);
(CryptoJS.algo.AES.keySize = 32),
(CryptoJS.algo.EvpKDF.cfg.iterations = 1e4),
(CryptoJS.algo.EvpKDF.cfg.keySize = 32);
var r = CryptoJS.AES.decrypt(secret, i.toString());
return (out = hex2a(r)), out;
}
this is when it calls the function and returns the file if it was successfully decrypted.
var msg="base64 of the salted encrypted file via cryptojs"
function proceed() {
var pass=document.getElementById('textfield2').value;
a=decoder(msg, pass);
if (a.search('{version')>-1) {
document.getElementById('status').innerHTML="SUCCESS";
download("result.json",a);
} else {
document.getElementById('status').innerHTML="FAILED";
}
I have tried this(windows openssl.exe cli 1.1) and got an error about -iter and other param. dont know how to give it key size 32 and iteration and evpkdf and hatever that js file does to decrypt.
OpenSSL.exe enc -aes-256-cbc -md md5 -d -pass pass:"simpletext" -in "tiny.bin" -out "result.txt"