Skip to content

Instantly share code, notes, and snippets.

@skarllot
Created April 14, 2025 21:02
Show Gist options
  • Save skarllot/9e659f9da43d7b7208f0847b2271e4a4 to your computer and use it in GitHub Desktop.
Save skarllot/9e659f9da43d7b7208f0847b2271e4a4 to your computer and use it in GitHub Desktop.
Convert binary file to base-64 using Powershell
$filePath = "C:\path\to\your\file.txt"
$outputPath = "C:\path\to\output\encodedFile.txt"
# Read the file content as bytes
$fileContent = [System.IO.File]::ReadAllBytes($filePath)
# Convert the byte array to a Base64 string
$base64String = [Convert]::ToBase64String($fileContent)
# Output the Base64 string to a new file
[System.IO.File]::WriteAllText($outputPath, $base64String)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment