Base-64 encoding is a way of taking binary data and turning it into text so that it's more easily transmitted in things like e-mail and HTML form data. I had few requirement to convert / encode text string to Base64 string and vice versa, From encoded Base64 string to convert/decode to normal string.
Related Articles: Powershell GUI encode decode images
In the first script to encode a text string I am using .net object [System.Text.Encoding] and [System.Convert].
#Convert To Base64 $readableText = 'This is Powershell!' $encodedBytes = [System.Text.Encoding]::UTF8.GetBytes($readableText) $encodedText = [System.Convert]::ToBase64String($encodedBytes) $encodedText
This is vice versa process to decode convert base 64 string to readable format. I am using same .net object [System.Text.Encoding] and [System.Convert].
#Convert from Base64 $encodedValue = 'VGhpcyBpcyBQb3dlcnNoZWxsIQ==' $decodedBytes = [System.Convert]::FromBase64String($encodedValue) $decodedText = [System.Text.Encoding]::Utf8.GetString($decodedBytes) $decodedText
Below are some other other format you can use to base convert (encode decode) text string to.
[System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($encodedText)) [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($encodedText)) [System.Text.Encoding]::BigEndianUnicode.GetString([System.Convert]::FromBase64String($encodedText)) [System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String($encodedText))
Download script here or it is also available on github.com.
Useful Articles
Powershell WPF Charts dashboard demo
Part 1: Create WPF XAML powershell GUI form with Visual studio
Part 2: Powershell and WPF: Build GUI applications tutorial
Part 3: Create shorter Microsoft Powershell WPF automated clean script
Powershell PoshGUI: Convert user to SID and vice versa using
Microsoft Powershell GUI: Change Internet Options connections Lan settings proxy server grayed out
Get-PSRepository WARNING Unable to find module repositories
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send
Creating an internal PowerShell module repository
How to sign PowerShell ps1 scripts