Last active
September 23, 2024 10:00
-
-
Save semick-dev/c7b66b4c3b72c0c138f7de0ac520c00e to your computer and use it in GitHub Desktop.
`pwsh` base64 encode/decode scraps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🚀