what are the differences between PHP base64_encode and *nix base64
open console in your browser, type atob('dGVzdAo=')
:
(source: gyazo.com)
You have extra character in your input. And that is 0x0A
(LF).
The linux base64
has a new line at the end.
When doing an echo it gives me this:
MacPro:~ bardiir$ echo 'test'
test
MacPro:~ bardiir$
I'd guess you might have an included line-ending in the unix one as echo is probably appending a newline character even if you pipe it throuch to the base64 encode.
echo
usually outputs a new line character at the end of the string, to suppress that use the -n
switch:
$ echo -n 'test' | base64
dGVzdA==
Similarly for PHP:
$ php
<?php
echo base64_encode("test\n");
?>
dGVzdAo=