{"id":478,"date":"2014-11-17T15:17:50","date_gmt":"2014-11-17T20:17:50","guid":{"rendered":"http:\/\/adsecurity.org\/?p=478"},"modified":"2014-11-13T20:57:40","modified_gmt":"2014-11-14T01:57:40","slug":"powershell-encoding-decoding-base64","status":"publish","type":"post","link":"https:\/\/adsecurity.org\/?p=478","title":{"rendered":"PowerShell Encoding &#038; Decoding (Base64)"},"content":{"rendered":"<p>PowerShell provides an easy method for Base64 encoding and decoding.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Encoding:<\/span><\/strong><\/p>\n<blockquote><p>$Text = &#8216;This is a secret and should be hidden&#8217;<br \/>\n$Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text)<br \/>\n$EncodedText =[Convert]::ToBase64String($Bytes)<br \/>\n$EncodedText<\/p><\/blockquote>\n<p>The result is this base64 encoded text:<br \/>\nVABoAGkAcwAgAGkAcwAgAGEAIABzAGUAYwByAGUAdAAgAGEAbgBkACAAcwBoAG8AdQBsAGQAIABiAGUAIABoAGkAZABlAG4A<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Decoding:<\/strong><\/span><br \/>\nDecoding the base64 encoded blob using PowerShell is simple.<\/p>\n<blockquote><p>$EncodedText = &#8220;VABoAGkAcwAgAGkAcwAgAGEAIABzAGUAYwByAGUAdAAgAGEAbgBkACAAcwBoAG8AdQBsAGQAIABiAGUAIABoAGkAZABlAG4A&#8221;<br \/>\n$DecodedText = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($EncodedText))<br \/>\n$DecodedText<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PowerShell provides an easy method for Base64 encoding and decoding. Encoding: $Text = &#8216;This is a secret and should be hidden&#8217; $Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text) $EncodedText =[Convert]::ToBase64String($Bytes) $EncodedText The result is this base64 encoded text: VABoAGkAcwAgAGkAcwAgAGEAIABzAGUAYwByAGUAdAAgAGEAbgBkACAAcwBoAG8AdQBsAGQAIABiAGUAIABoAGkAZABlAG4A Decoding: Decoding the base64 encoded blob using PowerShell is simple. $EncodedText = &#8220;VABoAGkAcwAgAGkAcwAgAGEAIABzAGUAYwByAGUAdAAgAGEAbgBkACAAcwBoAG8AdQBsAGQAIABiAGUAIABoAGkAZABlAG4A&#8221; $DecodedText = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($EncodedText)) $DecodedText &nbsp; &nbsp;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,2],"tags":[255,254,253,575],"class_list":["post-478","post","type-post","status-publish","format-standard","hentry","category-powershell","category-technical-reference","tag-base64","tag-base64decoding","tag-base64encoding","tag-powershell","item-wrap"],"_links":{"self":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=478"}],"version-history":[{"count":1,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/478\/revisions"}],"predecessor-version":[{"id":479,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/478\/revisions\/479"}],"wp:attachment":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}