July 21, 2018

PowerShell :: Convert a binary file to Base64

PowerShell ISE logo
(Last Updated On: 14th September 2016)

Hi,

So occasionally I have need to encode files to Base64 and if those files are not simple text then it needs to be done at a binary level. This simple script in PowerShell does that for you, you simply set the $inputFilePath and $ouputFilePath then execute. It outputs to a file as the output string gets large very quickly.

$inputFilePath = "C:\input.file"
$outputFilePath = "C:\output.txt"

[System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($inputFilePath)) > $outputFilePath

This script is designed in tandem with PowerShell :: Convert Base64 to a binary file.

Previous «
Next »

Simon is a sysadmin for a global financial organisation and specialises in Windows, security and automation.

2 Comments

  1. Pingback: an intro to macro malware – Synack
  2. Pingback: PowerShell :: Convert Base64 to a binary file – Synack

Leave a Reply

Subscribe to SYNACK via Email

%d bloggers like this: