Nov 17

PowerShell Encoding & Decoding (Base64)

PowerShell provides an easy method for Base64 encoding and decoding.


$Text = ‘This is a secret and should be hidden’
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text)
$EncodedText =[Convert]::ToBase64String($Bytes)

The result is this base64 encoded text:

Decoding the base64 encoded blob using PowerShell is simple.

$DecodedText = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($EncodedText))



Trimarc helps companies and organizations improve their security to better protect against and detect attacks.
Visit TrimarcSecurity.com for more information.

(Visited 29,942 times, 79 visits today)