What is the difference between base 64 and MIME 64 base?

I just spent too much time banging my head against the SMTP server because he did not like the base64 encoded credentials I used. It turns out that when I chose NOT to use perl, as it requires a lot of instructions on the Internet, I made a big mistake. Why is this? I thought base64 was the only 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

It is thus perlunique in its output, and my server requires it.

Why am I getting different results?

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

+6
source share
2 answers

Perl ; " Bash <<<" " ". ( , man- Ubuntu Xenial), Bash herestrings ( <<<) , , <<<, 'ASDF1234asdf\n', Perl ( herestring) 'ASDF1234asdf'. , .

, printf, :

$ printf %s ASDF1234asdf | base64
QVNERjEyMzRhc2Rm
+10

base64, :

$ perl -MMIME::Base64 -e 'print encode_base64("ASDF1234asdf")'
QVNERjEyMzRhc2Rm
$ perl -MMIME::Base64 -e 'print encode_base64("ASDF1234asdf\n")'
QVNERjEyMzRhc2RmCg==
$ echo -ne "my_user_name@my_domain.com" | base64
bXlfdXNlcl9uYW1lQG15X2RvbWFpbi5jb20=
$ echo -ne "my_user_name@my_domain.com\n" | base64
bXlfdXNlcl9uYW1lQG15X2RvbWFpbi5jb20K
+5

All Articles