Encode / Decode .EXE into Base64

The problem was caused by: Get-Content without -raw splits the file into an array of lines thus destroying the code Text.Encoding interprets the binary code as text thus destroying the code Out-File is for text data, not binary code The correct approach is to use IO.File ReadAllBytes: $base64string = [Convert]::ToBase64String([IO.File]::ReadAllBytes($FileName)) and WriteAllBytes to decode: [IO.File]::WriteAllBytes($FileName, … Read more

Write Base64-encoded image to file

Assuming the image data is already in the format you want, you don’t need ImageIO at all – you just need to write the data to the file: // Note preferred way of declaring an array variable byte[] data = Base64.decodeBase64(crntImage); try (OutputStream stream = new FileOutputStream(“c:/decode/abc.bmp”)) { stream.write(data); } (I’m assuming you’re using Java … Read more