How to convert string to Base64 and vice versa using Powershell

For debugging purposes I needed a quick way to convert Base64 encoded string. My opinion is that  the easiest way to achieve is to use Powershell.

Here is the example how to convert string "Hello World" to Base64 using ToBase64String method:

PS C:\Temp>$b  = [System.Text.Encoding]::UTF8.GetBytes("Hello World")
PS C:\Temp>[System.Convert]::ToBase64String($b)
SGVsbG8gV29ybGQ=

And here is the example how to decode Base64 string using FromBase64String method:

PS C:\Temp>$b  = [System.Convert]::FromBase64String("SGVsbG8gV29ybGQ=")
PS C:\Temp>[System.Text.Encoding]::UTF8.GetString($b)
Hello World


More about using ToBase64String and FromBase64String methods check:
http://msdn.microsoft.com/en-us/library/system.convert.frombase64string.aspx
http://msdn.microsoft.com/en-us/library/system.convert.tobase64string.aspx
 

7 comments:

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. If You Experience Something Like ...: How To Convert String To Base64 And Vice Versa Using Powershell >>>>> Download Now

      >>>>> Download Full

      If You Experience Something Like ...: How To Convert String To Base64 And Vice Versa Using Powershell >>>>> Download LINK

      >>>>> Download Now

      If You Experience Something Like ...: How To Convert String To Base64 And Vice Versa Using Powershell >>>>> Download Full

      >>>>> Download LINK Ls

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. thanks for the tutorial. used it for decoding some MDT variables :)

    ReplyDelete
  4. do this first to be able to reference [System.Convert]
    PS C:\Temp> add-type -AssemblyName System

    ReplyDelete
  5. do this first to be able to reference [System.Convert]
    PS C:\Temp> add-type -AssemblyName System

    ReplyDelete

How to check EMBG (Unique Master Citizen Number) using regex

In this post, I will share my implementation of how to check if some number looks like EMBG or Unique Master Citizen Number. For those of yo...