I'm attempting to decode an attachment in an email file from base64 and save it to disk.
For testing purposes, this is my code. Where input.txt contains just the base64 encoded data, which is an HTML file.
$file = "C:\input.txt"
$data = Get-Content $file
[System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($data)) > out.html
The decoding works fine, and it generates a new file that contains all of the lines, and is visibly identical to the original attachment. The problem is that the output file is twice the size (actually (filesize*2)+6 bytes, in this case).
Am I decoding this improperly? I've also tried UTF8 instead of ASCII... same result.