Search code examples
bashcommand-linebase64decodepassword-encryption

How do I get hex blocks from a base 64 encoded string?


In this article and this XKCD, they both show the password data as groupings of hexadecimal.

However, in the file it's base64 encoded. What could I use to match that output with bash scripting? I've tried:

echo -n "7WkoOEfwfTTioxG6CatHBw==" | base64 -d
echo -n "7WkoOEfwfTTioxG6CatHBw==" | openssl enc -d -base64

What is it they are doing, and how do I decode them to hex blocks?

xkcd Encryptic


Solution

  • If I understand this correctly, I think the requirement is to translate a base64 encoded string to a hex string in blocks of 8 bytes (16 hex digits). If so, od -t x8 -An, after the base64 decoding will get you there:

    $ echo -n "7WkoOEfwfTTioxG6CatHBw==" | base64 -d | od -t x8 -An
     347df047382869ed 0747ab09ba11a3e2
    $