jeramyRR

jeramyRR

I am trying to decode an Azure Storage Key that’s supposedly base64 encoded, but I’m getting all kinds of wonkey characters. Example:

Base.decode64! "ZG2p8/z2ATu8NVLBXmeFtkX9chpkbk2EK9fH4qVKxvC//mSlIdsqzvZpNa4k7tPPR86RmiGkdi0BLwAEtPbkXA==" |> String.codepoints

Results in:

[
  "d",
  "m",
  <<169>>,
  <<243>>,
  <<252>>,
  <<246>>,
  <<1>>,
  ";",
  <<188>>,
  "5",
  "R",
  <<193>>,
  "^",
  "g",
  <<133>>,
  <<182>>,
  "E",
  <<253>>,
  "r",
  <<26>>,
  "d",
  "n",
  "M",
  <<132>>,
  "+",
  <<215>>,
  <<199>>,
  <<226>>,
  <<165>>,
  "J",
  <<198>>,
  <<240>>,
  <<191>>,
  <<254>>,
  "d",
  <<165>>,
  "!",
  <<219>>,
  "*",
  <<206>>,
  <<246>>,
  "i",
  "5",
  <<174>>,
  "$",
  <<238>>,
  <<211>>,
  <<207>>,
  "G",
  "Α",
  ...
]

This definitely isn’t correct, or I’m not thinking about something correctly here. Is there something I need to do special for utf8 encoded strings?

Thanks for the help,
Jeramy

Showing Posts 1 to 5

massimo

massimo

It’s correct

the decoded string contains those characters

echo "ZG2p8/z2ATu8NVLBXmeFtkX9chpkbk2EK9fH4qVKxvC//mSlIdsqzvZpNa4k7tPPR86RmiGkdi0BLwAEtPbkXA==" | base64 -D -i - | hexdump -c
0000000   d   m   �   �   �   � 001   ;   �   5   R   �   ^   g 205   �
0000010   E   �   r 032   d   n   M 204   +   �   �   �   �   J   �   �
0000020   �   �   d   �   !   �   *   �   �   i   5   �   $   �   �   �
0000030   G   � 221 232   !   �   v   - 001   /  \0 004   �   �   �   \
0000040
jeramyRR

jeramyRR OP

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.

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/ comes out fine.

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

jeramyRR

jeramyRR OP

Looks like I may be able to remove all unprintable characters, but I’m not sure that’s going to work as far as Azure looking for the fully signed string using the full decoded shared key.

jeramyRR

jeramyRR OP

We can close this thread. I got it figured out. There was nothing wrong with the key. There was however a mistake in my spelling.

massimo

massimo

base64decode.org is simply removing the non printable characters.
try on this one and see the difference https://codebeautify.org/base64-decode

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews