More actions
On The Command Line
- To decode messages which are in Base 64 simply copy the content of the message into a text file. For example, lets decode the base 64 listed below.
TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=
To do so copy this text into a file named text.txt. Then cat that file and pipe the output through the base64 decoder.
cat text.txt | base64 -d
And tahdah! The message appears,
Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.
- To encode a message as base 64 simply run base64 on a file.
File as is, cat file This is a text file
File in base64 cat file | base64 VGhpcyBpcyBhIHRleHQgZmlsZQo=
For more information about how to use the base64 command in the terminal run,
base64 --help
Or read the wikipedia page about the encoding here.
With Python3
- Encode
>>> import base64 >>> message="blah" >>> message_bytes = message.encode('utf8') >>> base64_bytes = base64.b64encode(message_bytes) >>> base64_message = base64_bytes.decode('utf8') >>> print(base64_message) YmxhaA==
- Decode
>>> import base64 >>> message="YmxhaA==" >>> base64.b64decode(message) b'blah'