I'm stuck on getting Crypto-JS to work for our use case. I'm doing things like the following:
cipher=CryptoJS.enc.Hex.parse(paddinghex); // create a WordArray based on a hex version of the padding
alert(cipher.toString(CryptoJS.enc.Base64)); // check for well-formed Base64
cparms = CryptoJS.format.OpenSSL.parse(cipher.toString(CryptoJS.enc.Base64)); // create CipherParams
cparms.iv = '0000';
cparms.key = 'wombats';
var decrypted=CryptoJS.Rabbit.decrypt(cparms,key,{iv: my_iv});
alert('decrypt: ' + decrypted.toString(CryptoJS.enc.Latin1)); // display output
Despite explicitly setting an iv and key, I get a different result every time I decrypt. At first I thought it was a problem with something randomized, like the iv or salt, but this issue occurs even when I'm explicitly setting the iv as in the example above. As far as I can tell, Rabbit doesn't use a salt. Has anyone been able to get consistent results out of it?
I'm only having trouble when I try to construct my own ciphertext. I can successfully encrypt then decrypt with Rabbit using Crypto-JS using the following because whatever I'm missing is automagically handled in the CipherParams that encrypt() built:
var msg="this is a friendly message.";
var key="keyword";
var encrypted=CryptoJS.Rabbit.encrypt(msg,key);
var decrypted=CryptoJS.Rabbit.decrypt(encrypted,key);
alert('decrypted: ' + decrypted.toString(CryptoJS.enc.Latin1));