SGVsbG8sIHdvcmxkIQ== I have to write two scripts, one for Windows Server and another for Ubuntu Server. To illustrate, if my bash script runs:
echo -n 'BASE64' | base64
the result is QkFTRTY0. If my PowerShell Script runs:
[System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes('BASE64'))
the result is QgBBAFMARQA2ADQA. Is important get the same PowerShell string in Linux. Anybody knows why this difference and some solution to my problem? I think that the problem is related to Unix's UTF-8 encoding, but I can't find a solution. I can decode the PowerShell output in Linux, but I can't encode a string in Linux and get the same result as PowerShell. A bash solution is optimal, but a C/C++ code solution or guide works too.
[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes('BASE64'))?Unicode.GetBytesin Linux.UTF8.GetBytesreturns the correct result.