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?
To decode a file with contents that are base64 encoded, you simply provide the path of the file with the --decode flag. As with encoding files, the output will be a very long string of the original file. You may want to output stdout directly to a file.
The difference between Base64 and hex is really just how bytes are represented. Hex is another way of saying "Base16". Hex will take two characters for each byte - Base64 takes 4 characters for every 3 bytes, so it's more efficient than hex.
Show activity on this post. In base64 encoding, the character set is [A-Z, a-z, 0-9, and + /] . If the rest length is less than 4, the string is padded with '=' characters. ^([A-Za-z0-9+/]{4})* means the string starts with 0 or more base64 groups.
Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The term Base64 originates from a specific MIME content transfer encoding.
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
$
Output the hex code without newline:
echo "<BASE64>" | base64 -d | hexdump -v -e '/1 "%02x" '
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With