title: Problems with AES in crypto-js and pycrypto
body: <p>I try to implement a communication between</p>
  
  <ul>
  <li><p><a href="http://code.google.com/p/crypto-js/" rel="nofollow">crypto-js</a> (a javascript crypto library) </p></li>
  <li><p>and <a href="https://www.dlitz.net/software/pycrypto/" rel="nofollow">pycrypto</a> (a python crypto library)</p></li>
  </ul>
  
  <p>On the <em>python server side</em> I encrypt a string with an <code>iv</code> and a <code>passphrase</code> and send the iv with the encrypted text base64 encoded to the <em>javascript client side</em>. Then I want to <code>decrypt</code> the string with the passphrase the user can enter.</p>
  
  <p><strong>python - server</strong></p>
  
  <pre><code>from Crypto.Cipher import AES
  from Crypto import Random
  
  iv = Random.get_random_bytes(16)
  key = "1234567812345678"
  aes = AES.new(key, AES.MODE_CFB, iv)
  encrypted_text = base64.b64encode(aes.encrypt("this is a test.."))
  iv = base64.b64encode(iv)
  # send iv, encrypted_text to client
  </code></pre>
  
  <p><strong>javascript - client</strong></p>
  
  <pre><code>// &lt;script type="text/javascript" 
          src="http://crypto-js.googlecode.com/files/2.5.3-crypto-sha1-hmac-pbkdf2-blockmodes-aes.js"&gt;
     &lt;/script&gt;
  // text, and iv is base64encoded from the python script
  // key is a string from an &lt;input type='text'&gt;
  decrypted = Crypto.AES.decrypt(text, key, {iv: iv, mode: new Crypto.mode.CFB});
  </code></pre>
  
  <p>With this example I get a javascript error</p>
  
  <pre><code>Uncaught URIError: URI malformed
  </code></pre>
  
  <p>But this is just one example - I tried every constellation of base64 encodings/decodings I could think of. I also tried to changed the Mode. But these are all random tests and I want to understand what I really have to do. </p>
  
  <ul>
  <li>What encoding does the crypt-js want? </li>
  <li>Which mode should I chose?</li>
  <li>Is there something I should change on the python server side?</li>
  <li>what is about padding? Could there be the fault?</li>
  <li>any other javascript libraries you can recommend?</li>
  </ul>
  
  <p>thank you very much and kind reagards,
  samuirai</p>