Skip to content

Instantly share code, notes, and snippets.

@ptr0x1
Created November 7, 2017 10:57
Show Gist options
  • Save ptr0x1/00c84894f9a784b7af7ab73594e89e39 to your computer and use it in GitHub Desktop.
Save ptr0x1/00c84894f9a784b7af7ab73594e89e39 to your computer and use it in GitHub Desktop.
powershell b64 encode
$fileName = "File1.txt"
$fileContent = get-content $fileName
$fileContentBytes = [System.Text.Encoding]::UTF8.GetBytes($fileContent)
$fileContentEncoded = [System.Convert]::ToBase64String($fileContentBytes)
$fileContentEncoded set-content ($fileName + ".b64")
#DECODE
$fileName = "File1.txt"
$fileContent = get-content $fileName
$bytes = [Convert]::FromBase64String($fileContent)
[IO.File]::WriteAllBytes($filename, $bytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment