title: How to fully decode a base64 string in PHP?
body: <p>I'm trying to implement the Google Safebrowsing update API v4 in PHP.
  But I can't figure how to correctly decode the rawHashes.</p>
  <p>(The rawHashes are 4-bytes-truncated sha256 hashes and then concatenated).</p>
  <p>I am trying the native base64_decode of PHP but I can't fully decode the string, and I don't know what the next step is.</p>
  <p>According to the API <a href="https://developers.google.com/safe-browsing/v4/reference/rest/v4/threatListUpdates/fetch#RawHashes" rel="nofollow noreferrer">documentation</a> here's how the rawhashes are encoded :</p>
  <pre><code>string (bytes format)
  The hashes, in binary format, concatenated into one long string. Hashes are sorted in lexicographic order. For JSON API users, hashes are base64-encoded.
  A base64-encoded string.
  </code></pre>
  <p>I an very simply decoding the string like so:</p>
  <pre class="lang-php prettyprint-override"><code>$decoded = base64_decode($rawHashes);
  </code></pre>
  <p>The base64 encoded string look like this:</p>
  <pre><code>&quot;AAAIYAAAC90AABOxAAAjDgAALZIAAEbKAABIHwAA...&quot;
  </code></pre>
  <p>And the base64 decoded string look like this:</p>
  <pre><code>b&quot;\x00\x00\x08`\x00\x00\vÝ\x00\x00\x13±\x00\x00#\x0E\x00\x00-’\x00\x00FÊ\x00\x00H\x1F\x00\x00^\x06\x00\x00bF\x00\x00h²&quot;
  </code></pre>
  <p>As you can see something is not right and I must have missed a step but I can't figure which one.</p>