I'm trying to use Powershell to Base64 encode an mp3 audio file (for uploading via API call), but for some reason the resulting Base64 encoded text isn't right. Here is my code:
$fileContent = Get-Content $recording -Encoding UTF8
$fileContentBytes = [System.Text.Encoding]::UTF8.GetBytes($fileContent)
$fileContentEncoded = [System.Convert]::ToBase64String($fileContentBytes)
$fileContentEncoded | set-content ("c:\output.b64")
I compare my resulting text from this script with the resulting text from one of the free online base64 encoders (which I know is correct), and I get a different string of text.
Can anyone help me?