base64 encoding decoding with openssl
Thu, 08/30/2012 - 16:28 — sandipBase64 encoding with openssl:
echo -n 'encode this with base64' | openssl enc -base64
ZW5jb2RlIHRoaXMgd2l0aCBiYXNl NjQ=
Base64 decoding with openssl:
echo 'ZW5jb2RlIHRoaXMgd2l0aCBi YXNlNjQ=' | openssl enc -base64 -d
encode this with base64
- sandip's blog
- Login or register to post comments
- Read more
encode / decode base64 file
Thu, 02/07/2008 - 10:30 — sandipI use squrrelmail in text mode and recently I've had to retrieve a password at Dell. The reset password email however comes with html embeded in base64 encoded text. So my webmail did not show up the embeded html link. With some knowledge of uudecode, I was able to view the exact link to reset the password.
The sharutils package contains the GNU utilities uuencode and uudecode.
Here's a brief background and usage:
uuencode is a program that encodes binary files as plain ASCII text so that they can be sent through electronic mail. The program expands single characters that can't be viewed or printed as normal text into pairs of text characters, and the resulting encoded file is somewhat larger than the original binary file. This process is necessary to prevent mail, news, and terminal programs from misinterpreting the non-text characters in binary files as special instructions.
$ cat test.txt
hello world!
$ uuencode -m test.txt test.txt > test.txt.base64
$ cat test.txt.base64
begin-base64 644 test.txt
CmhlbGxvIHdvcmxkIQoKCg==
====
$ rm test.txt
$ uudecode test.txt.base64
$ cat test.txt
hello world!
First I copied over the actual base64 encoded text from my local email folder which looks similar to:
$ cat dell_reset
DQpUaGlzIGVtYWlsIHdhcyBzZW50 IHRvIHlvdSBpbiByZXNwb25zZSB0by B5b3VyIHJlcXVl
... ...
bGluayBoYXMgYSBsaWZlIHNwYW4g b2YgdGhyZWUgZGF5cyBvbmx5Ljxici AvPg0KPGJyIC8+DQo=
I then added text in the beginning and end to specify the base64 encoded as below:
$ cat - dell_reset <<<"begin-base64 644 dell_reset.txt" > dell_reset.base64
$ echo "====" >> dell_reset.base64
$ cat dell_reset.base64
begin-base64 644 dell_reset.txt
DQpUaGlzIGVtYWlsIHdhcyBzZW50 IHRvIHlvdSBpbiByZXNwb25zZSB0by B5b3VyIHJlcXVl
... ...
bGluayBoYXMgYSBsaWZlIHNwYW4g b2YgdGhyZWUgZGF5cyBvbmx5Ljxici AvPg0KPGJyIC8+DQo=
====
The text was then decoded using:
$ uudecode dell_reset.base64
$ cat dell_reset.txt
This email was sent to you in response to your request to modify your Dell.com account.<br />
Click the link below to go to the Dell site and modify your account:<br />
... ...