PowerShell – Base64 Encode/Decode a string

An easy way to convert data to/from base64 (or uuencode/uudecode, quoted-printable, url encode/url decode, JIS, Yenc, hex, or even creating md5 or sha1 hashes) is to use the NetCmdlets convert-data cmdlet. To encode:

PS C:\> convert-data -data "Hello, World!" -to base64

Data                                                             Size Format
----                                                             ---- ------
SGVsbG8sIFdvcmxkIQ==                                               20 base64

To decode:

PS C:\> convert-data -data $encoded.Data data -from base64

Data                                                             Size Format
----                                                             ---- ------
Hello, World!                                                      13 Plain

Technorati Tags: , ,

Print | posted on Friday, August 29, 2008 1:24 PM

Feedback

No comments posted yet.

Your comment:





 
 

Copyright © Lance Robinson

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski