title: Storing binary data in Google Secret Manager
body: <p>I'm using <a href="https://cloud.google.com/secret-manager" rel="nofollow noreferrer">Google Secret Manager</a> for the first time to store some binary data. When I access the secret, it seems to have a different encoding or format.</p>
  
  <p>The actual data is a certificate bundle, but I've been able to reproduce the issue using smaller binary data. Steps to reproduce:</p>
  
  <ol>
  <li><p>Create a file with binary data:</p>
  
  <pre><code>echo -e -n '\xed\xfe' &gt; secret.txt
  </code></pre></li>
  <li><p>Create the secret and version:</p>
  
  <pre><code>gcloud secrets create "my-secret" \
    --data-file ./secret.txt \
    --replication-policy "automatic"
  </code></pre></li>
  <li><p>Access the secret and save the result to a file:</p>
  
  <pre><code>gcloud secrets versions access latest --secret "my-secret" &gt; result.txt
  </code></pre></li>
  <li><p>Compare the two files:</p>
  
  <pre><code>od -t x1 secret.txt  # ed fe
  od -t x1 result.txt  # 3f 3f 0a
  </code></pre></li>
  </ol>
  
  <p>Why is the result different? Do I have to do something extra to get Google Secret Manager to work with binary data?</p>