encode / decode base64 file

I 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

$ 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
... ...

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
... ...

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 />
... ...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Solaris 10

In case you are using Solaris 10 and installing more software packages on the machine is not an option, then you have to use the uudecode/uuencode mechanism. The commands recode and base64 are not avaulable in that case.
Thanks for this information, I used it and appreciate it.

use the base64 command:

use the base64 command: base64 -d FILE


recode for converting character sets

Additionally, you could use `recode` which has a lot of other options for converting files between various character sets and usages.

You can get recode here.

Or, install via yum:

yum install recode

Example to decode quoted-printable (common encoding used for text email attachments):

recode /qp.. < test.qp > test.txt

`info recode` for the manual.

Post new comment

  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Enter the characters shown in the image.