title: SHA256 implementation using Base64 for input and output
body: <p>I've been asked to develop the company's backoffice for the iPad and, while developing the login screen, I've ran into an issue with the authentication process.</p>
  
  <p>The passwords are concatenated with a salt, hashed using SHA-256 and stored in the database.
  The backoffice is Flash-based and uses the <strong>as3crypto</strong> library to hash then password+salt and my problem is that the current implementation uses Base64 for both input and output.</p>
  
  <p><a href="http://crypto.hurlant.com/demo/" rel="nofollow">This site</a> demonstrates how this can be done: just select Hash and select Base64 for both input and output format and fire away. So far, all my attempts have yielded different results from the ones this site (and the backoffice code) give me.</p>
  
  <p>While I think that in theory it should be relatively simply:</p>
  
  <ol>
  <li>Base64 encode the pass+salt</li>
  <li>Hash it using SHA-256</li>
  <li>Base64 encode the result again</li>
  </ol>
  
  <p>so far I haven't been able to do this and I'm getting quite the headache to be honest.
  My code is becoming a living maze, i'll have to redo-it tomorrow I reckon.</p>
  
  <p>Any ideas?
  Cheers and thanks in advance</p>
  
  <p>PS: Here's the Backoffice's Flash code for generating hashed passwords by the way:</p>
  
  <pre><code>var currentResult:ByteArray;
  var hash:IHash = Crypto.getHash('sha256');
  var data:ByteArray = Base64.decodeToByteArray(str + vatel);
  currentResult = hash.hash(data);
  return Base64.encodeByteArray(currentResult).toString();
  </code></pre>