Bash base64 has an additional character instead of an equals versus powershell

Viewed 86

If I do the following in powershell:

$b = [System.Text.Encoding]::UTF8.GetBytes("helloworld")

[System.Convert]::ToBase64String($b)

The output is:

aGVsbG93b3JsZA==

If I go into bash and do the same thing:

echo "helloworld" | base64 then the result is:

aGVsbG93b3JsZAo=

So in bash, instead of the first = its an o. Why is that?

1 Answers

In bash,

echo "helloworld" | base64

will add a newline character (\n or 0A in hex) to helloworld. Use

echo -n "helloworld" | base64

instead.

Related