# Problems properly decoding a base64 encoded string

**URL:** <https://forum.elixirforum.com/t/problems-properly-decoding-a-base64-encoded-string/19185>\
**Category:** Questions\
**Tags:** decoding\
**Created:** [January 6, 2019, 1:41am UTC](https://forum.elixirforum.com/t/problems-properly-decoding-a-base64-encoded-string/19185 "2019-01-06T01:41:41Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![jeramyRR](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jeramyrr/32/722_2.png) [@jeramyRR](https://forum.elixirforum.com/u/jeramyRR)\
**Post date:** [January 6, 2019, 2:18am UTC](https://forum.elixirforum.com/t/problems-properly-decoding-a-base64-encoded-string/19185/3 "2019-01-06T02:18:11Z")

</div>

I’m unable to use the decoded string to reencode other strings it seems. When I try to create a signature using :crypto.hmac(:sha256, decoded\_shared\_key, “This is a test”) I get back gibberish again.

```elixir
shared_key = "ZG2p8/z2ATu8NVLBXmeFtkX9chpkbk2EK9fH4qVKxvC//mSlIdsqzvZpNa4k7tPPR86RmiGkdi0BLwAEtPbkXA=="
decoded = Base.decode64! shared_key
:crypto.hmac(:sha256, decoded, "This is a test")
<<22, 6, 194, 235, 170, 235, 226, 199, 1, 90, 191, 4, 222, 153, 97, 47, 90, 238,
  217, 126, 252, 23, 12, 117, 221, 127, 150, 78, 14, 236, 193, 141>>

```

That binary returned again contains invalid characters that aren’t recognized on the other side of my http request.

This is baffling me, because none of the other azure sdks (ruby, java, go, c#) have any problem with these keys.

Even using [https://www.base64decode.org/](https://www.base64decode.org/) comes out fine.

base64decode results: dm;5R^gErdnM+Jd!\*i5$GΑ!v-/\

---

_[View the full topic](https://forum.elixirforum.com/t/problems-properly-decoding-a-base64-encoded-string/19185)._
