What is the difference between base64 and MIME base 64?

Viewed 2561

I just spent way too much time banging my head against an SMTP server because it didn't like the base64 encoded credentials I was using. Turns out that when I chose NOT to use perl like so many instructions on the internet say to use, I was making a big mistake. Why is this? I thought base64 was a single standard.

Consider:

$ perl -MMIME::Base64 -e 'print encode_base64("ASDF1234asdf")'
QVNERjEyMzRhc2Rm

$ base64 <<<"ASDF1234asdf"
QVNERjEyMzRhc2RmCg==

$ python3.6 -m base64 <<<"ASDF1234asdf"
QVNERjEyMzRhc2RmCg==

$ python2.7 -m base64 <<<"ASDF1234asdf"
QVNERjEyMzRhc2RmCg==

$ perl -MMIME::Base64 -e "print encode_base64('my_user_name@my_domain.com')"
bXlfdXNlcl9uYW1lQG15X2RvbWFpbi5jb20=

$ base64 <<<"my_user_name@my_domain.com"
bXlfdXNlcl9uYW1lQG15X2RvbWFpbi5jb20K

So, perl is unique in its output and my server requires it that way.

Why am I getting different results?

How do you get the MIME/SMTP friendly output with something other than perl?

2 Answers
Related