与powershell相比,Bash base64有一个额外的字符,而不是等号



如果我在powershell中执行以下操作:

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

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

输出为:

aGVsbG93b3JsZA==

如果我进入bash并做同样的事情:

echo "helloworld" | base64则结果为:

aGVsbG93b3JsZAo=

所以在bash中,不是第一个=,而是o。为什么呢?

在bash中

echo "helloworld" | base64

将在helloworld上添加一个换行字符(十六进制的n0A)。使用

echo -n "helloworld" | base64

最新更新