Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm looking to encode an input string to base32 encoding directly from the shell. I'm looking to do this in ubuntu, but I imagine flavor doesn't particularly matter here.

Are there any existing linux/unix tools out there to simply do this?

Something along the lines of:

-bash-3.2$ echo -n 'hello' | base32
share|improve this question

1 Answer 1

up vote 8 down vote accepted

Hmm, a quick package search doesn't give anything like a single, standalone utility.

On the other hand, it shows that there's an appropriate Perl library, and it's easy enough to whip up a quick perl script. Something like:

$ sudo apt-get install libmime-base32-perl

And then a script like


use MIME::Base32 qw( RFC );

undef $/;  # in case stdin has newlines
$string = <STDIN>;

$encoded = MIME::Base32::encode($string);

print "$encoded\n";


$ echo -n "hello" | ./

The fairly sparse CPAN entry is:

So, a minor change will let you do decodes, also.

share|improve this answer
Thanks, MIME::Base32 seems to do the trick. – jdev May 4 '12 at 22:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.