Wednesday, October 1, 2014

Single Line Base64 Decoder

If you have a chunk of Base64 encoded data and want to decode it, the quickest method is usually to find some online decoder. If you're worried about the sensitivity of the data or don't have access to a web browser or even the Internet you'll want to decode it locally.

To do this you'll need perl (should be installed on most linux distros). Given any file containing only Base64 encoded text, ex:
$ file base64_file
base64_file: ASCII text, with CRLF line terminators
$
The following command will decode the text:
(NOTE - the file must contain ONLY Base64 encoded text - any existing decoded data will break the process)
$ perl -MMIME::Base64 -e 'print decode_base64(join("",<>))' < base64_file >output
$ file output
output: HTML document, ASCII text, with CRLF line terminators
$
If done correctly the output file should contain the decoded data.

No comments:

Post a Comment