如果我在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
上添加一个换行字符(十六进制的n
或0A
)。使用
echo -n "helloworld" | base64
。