Skip to content

Instantly share code, notes, and snippets.

@semick-dev
Last active September 23, 2024 10:00
Show Gist options
  • Save semick-dev/c7b66b4c3b72c0c138f7de0ac520c00e to your computer and use it in GitHub Desktop.
Save semick-dev/c7b66b4c3b72c0c138f7de0ac520c00e to your computer and use it in GitHub Desktop.
`pwsh` base64 encode/decode scraps
$inputFile = "azure-sdk-qr-smaller.PNG"
$file = "re-rewritten.txt";
$test_out = "re-out.png"
# to base64
[System.Convert]::ToBase64String((Get-Content $inputFile -AsByteStream)) | Set-Content $file
# back to bytes
[Convert]::FromBase64String((Get-Content $file)) | Set-Content $test_out -AsByteStream
param(
$file="your-text-file.txt"
)
$ENCODED = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes((Get-Content $file -Raw)))
Write-Output $ENCODED
$DECODED = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($ENCODED))
Write-Output $DECODED
@danieljurek
Copy link

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment