title: Compute base64 encoded hash from a given hash?
body: <p>I created a file and input some random string into it.</p>
  
  <pre><code>touch tesseract &amp;&amp; echo 'TestTestTestTestTest' &gt; tesseract
  </code></pre>
  
  <p>Now if I use <code>openssl</code> to compute <code>base64</code> hash [<code>sha256</code>], I run this:</p>
  
  <pre><code>cat tesseract | openssl dgst -sha256 | openssl base64 -A
  </code></pre>
  
  <p>which returns me </p>
  
  <p><code>KHN0ZGluKT0gMzJjYjA1MTgzNDNhZmY2N2FlMmY5YzUwNDcwNGRiNGE5Njc5MzIyZWVlNTBmMjBiNTMzNjZlYTBiMDY2MWNlZgo=</code><br/></p>
  
  <p>Now I process this hash stepwise, as,</p>
  
  <pre><code>cat tesseract | openssl dgst -sha256 &gt; partialHash
  </code></pre>
  
  <p>which gives me </p>
  
  <p><code>(stdin)= 32cb0518343aff67ae2f9c504704db4a9679322eee50f20b53366ea0b0661cef</code></p>
  
  <p>Let this hash be <code>X</code>.
  Then I do this,</p>
  
  <pre><code>echo '32cb0518343aff67ae2f9c504704db4a9679322eee50f20b53366ea0b0661cef' &gt; partialHash
  cat partialHash | openssl base64 -A
  </code></pre>
  
  <p>I get a different result. Why is that?</p>
  
  <p>My reason for asking is because I use a binary, <code>hashdeep</code> which gives me hashes in form of <code>32cb0518343aff67ae2f9c504704db4a9679322eee50f20b53366ea0b0661cef</code> and I wish to convert them to <code>base64</code> encoded format as <code>hashdeep</code> is not capable of producing a <code>base64</code> output. So I pipe the intermediate hash to <code>openssl base64 -A</code>, but obtain a different result.</p>
  
  <p>What am I missing? How can I convert the non-encoded hash <code>X</code> [which is <code>32cb0518343aff67ae2f9c504704db4a9679322eee50f20b53366ea0b0661cef</code>] to proper <code>base64</code> encoded format? </p>
  
  <p>For simplicity purpose, we can assume that <code>X</code> is present in a file, <br/>created using <code>echo '32cb0518343aff67ae2f9c504704db4a9679322eee50f20b53366ea0b0661cef' &gt; file</code></p>