Skip to content

Instantly share code, notes, and snippets.

@bogdangrigg
Last active April 19, 2019 19:55
Show Gist options
  • Save bogdangrigg/eb426920a1cce3c5811847c2da5fe387 to your computer and use it in GitHub Desktop.
Save bogdangrigg/eb426920a1cce3c5811847c2da5fe387 to your computer and use it in GitHub Desktop.
base64 encode & decode
# encode
$Text = "Hidden secret!"
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text) # or Unicode.GetBytes($Text), if Unicode is not needed
$EncodedText =[Convert]::ToBase64String($Bytes)
$EncodedText
# decode
$EncodedText = “SABpAGQAZABlAG4AIABzAGUAYwByAGUAdAAhAA==”
$DecodedText = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($EncodedText))
$DecodedText
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment