ConvertBase64
A pair of PowerShell cmdlets for converting to and from Base64 strings.
Usage
The commands are simple and intuitive to use:
Convert to Base64
The easiest way to convert to Base64 is to simply pipe a text string in to the command:
"Hello World!" | ConvertTo-Base64
That outputs the Base64 representation of the input test:
SGVsbG8gV29ybGQh
The byte encoding of the input text can be configured with the -Encoding parameter. The default encoding is UTF8.
The command can also be used to convert raw byte arrays to Base64 with:
ConvertTo-Base64 -Bytes @(0, 1, 2)
A convenient alias exists for the command:
"Hello World!" | ctb
Convert from Base64
The ConvertFrom-Base64 command works in a similar fashion, simply pipe a Base64 payload into it:
"SGVsbG8gV29ybGQh" | ConvertFrom-Base64
And it will output the decoded text:
Hello World!
This too features an -Encoding parameter for configuring the byte encoding when decoding the text output.
But it can also output raw byte arrays:
"AAEC" | ConvertFrom-Base64 -OutputBytes
Which will result in a byte array:
0
1
2
This too comes with a similarly named alias:
"SGVsbG8gV29ybGQh" | cfb