Base64 is a binary-to-text encoding that converts binary data into a sequence of printable characters but limited to a set of 64 unique characters. In this tutorial we will see how to encode and decode string and file content using base64 command.
Encode String Using the base64 Command:
Open the terminal app (ctrl+alt+t) and run below command.
base64 <<< 'CONNECTwww.com'
Alternatively you can also use below command.
echo 'CONNECTwww.com' | base64
but the results are same.
Decode String Using the base64 Command:
Open the terminal app (ctrl+alt+t) and run below command to decode the string.
base64 -d <<< Q09OTkVDVHd3dy5jb20K
[OR]
echo 'Q09OTkVDVHd3dy5jb20K' | base64 -d
Encode File Using the base64 Command:
If you want to encode file.txt text file from your Home directory, then run below command.
base64 file.txt
Decode File Using the base64 Command:
If you want to decode, the above content then run below command.
base64 -d <<< Q09OTkVDVHd3dy5jb20KQnkKTWFuaWthbmRhbgo=