title: PHP openssl_encrypt in JavaScript with CryptoJS
body: <p>I have a problem generating the same ciphertext in JavaScript as provided in a  third party PHP server. The server side uses a simple one-liner to generate a key, but I can't find a way to do the same in my JavaScript client. </p>
  
  <p>I decided to use the CryptoJS library, from <a href="https://stackoverflow.com/questions/24337317/encrypt-with-php-decrypt-with-javascript-cryptojs" title="other answers">other SO answers </a>, and I did generate a ciphertext but it was different that the one from a PHP server.</p>
  
  <p>PHP encryption:</p>
  
  <pre><code>echo openssl_encrypt("5905","AES-256-CBC","FbcCY2yCFBwVCUE9R+6kJ4fAL4BJxxjdRcqy5rHVLwU=",NULL,"e16ce913a20dadb8");
  // phgygAJB3GA0sa4D9k/d8A==
  </code></pre>
  
  <p>I have tried several solutions from Stack Overflow which failed to create the same ciphertext.</p>
  
  <p>Also, the parameter "AES-256-CBC" in the PHP one-liner bothers me: I know what AES is, but I have no idea what those 256 or CBC parts are, and I don't know where to set those on the CryptoJS side.</p>
  
  <p>My current attempt:</p>
  
  <pre><code>var key = 'FbcCY2yCFBwVCUE9R+6kJ4fAL4BJxxjdRcqy5rHVLwU=';
  var iv = 'e16ce913a20dadb8';
  var encrypted = CryptoJS.AES.encrypt("5905", CryptoJS.enc.Hex.parse(key), { iv: CryptoJS.enc.Hex.parse(iv) });
  var r1 = encrypted.ciphertext.toString(); // def44f8822cfb3f317a3c5b67182b437
  var r2 = CryptoJS.enc.Base64.stringify(encrypted.ciphertext) // 3vRPiCLPs/MXo8W2cYK0Nw==
  </code></pre>
  
  <p>My guess is that I am missing "256" and "CBC" parameters somewhere in JavaScript.</p>