Archibald
Archibald

Reputation: 485

Base64 encoding from a website and terminal give two different results

I used following command on terminal

`echo admin:admin | base64`

It gives me following output

YWRtaW46YWRtaW4K

But when I used https://www.base64encode.org/ for the same string admin:admin it gives me following

YWRtaW46YWRtaW4=

Any reason for this?

Upvotes: 6

Views: 1508

Answers (1)

Archibald
Archibald

Reputation: 485

The reason this behaviour is the new line added by the echo command. Normally the echo command add a new line at the end which leads to a different encoding. Therefore if you use it with echo -n admin:admin | base64 the difference won't occur.

Upvotes: 8

Related Questions