title: How to encode md5 sum to base64 in Javascript
body: <p>I have a login web form, user writes his password and I must encrypt it on MD5 and the sum to base 64. I'm doing like this with CryptoJS:</p>
  
  <pre><code>var hash = CryptoJS.MD5(cred.password); // password is `password`
  cred.password = hash.toString(CryptoJS.enc.Base64); // X03MO1qnZdYdgyfeuILPmQ==  --  IT IS OK!
  </code></pre>
  
  <p>This works fine. Then I must convert the following string to MD5 and Base64 too:</p>
  
  <pre><code>var digest = "john.doe,"+hash.toString()+",QCiTzbXCAYA3AvDgYN3MuBwY/1i89q6TfW7aVS1Av1c=";
  </code></pre>
  
  <p>again I do:</p>
  
  <pre><code>var hash1 = CryptoJS.MD5(digest);
  digestResult = hash1.toString(CryptoJS.enc.Base64);
  </code></pre>
  
  <p>It returns <code>i4a9M2b6l+yBZLHc3bXWMA==</code> but the expected by the server for this conbination is <code>6R1HZqYJFfRQUA0L/hqCEA==</code></p>
  
  <p>I guess Crypto is not working for a base64/md5 inside the string to convert?</p>
  
  <p>I dont get why it returns bad</p>