Sometimes you need to deal with base64 strings, here are a couple commands that make it easy to encode/decode those strings using the terminal. I deal with various types of authentication strings a lot, which are often base64 encoded, and often need to quickly test and verify the base64 values I’m using.
In your terminal you have access to the base64 program from the coreutils package installed on your machine by default. Using a simple
echo statement we can encode/decode a base64 string. Here’s an example:
echo < string to interpret > | base64
echo testuser:testpass | base64
Decoding a base64 string just requires us to use the
echo < string to interpret > | base64 --decode
echo dGVzdHVzZXI6dGVzdHBhc3MK | base64 --decode