title: Crypto-js local side to php server side
body: <p>I have an app that use crypto-Js AES. The simulate working code is:</p>
  
  <pre><code>var ciphertext = CryptoJS.AES.encrypt('My_message', 'My_secret_key');
  console.log(ciphertext.toString()); 
  </code></pre>
  
  <p>the answer is:</p>
  
  <pre><code>U2FsdGVkX1/Dd3uAr/mdw5lVoBvq0UX5LHnNoX24JAM=
  </code></pre>
  
  <p>when I try to reproduce it server side I never get the same answer:</p>
  
  <pre><code>$passphrase='My_secret_key';
  $value='My_message';
  $salt = openssl_random_pseudo_bytes(8);
  $salt ='';
  $salted = '';
  $dx = '';
  while (strlen($salted) &lt; 48) {
   $dx = md5($dx.$passphrase.$salt, true);
   $salted .= $dx;
  }
  $key = substr($salted, 0, 32);
  $iv  = substr($salted, 32,16);
  $encrypted_data = openssl_encrypt($value, 'aes-256-cbc', $key, true, $iv);
  echo base64_encode($encrypted_data);
  </code></pre>
  
  <p>server side answer:</p>
  
  <pre><code>3jSTl1yR55lfTbz7f0o3Yw==
  </code></pre>
  
  <p>I must miss something but can't point out what. Local side can't touched.
  All help is welcome</p>