{"id":2450,"date":"2012-07-20T10:35:12","date_gmt":"2012-07-20T14:35:12","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=2450"},"modified":"2012-07-20T10:35:12","modified_gmt":"2012-07-20T14:35:12","slug":"friday-fun-powershell-crypto","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/","title":{"rendered":"Friday Fun PowerShell Crypto"},"content":{"rendered":"<p>I'm a big fan of codes, ciphers and secret messages. I obviously am a big PowerShell fan as well. So why not mash these things together? Today's Friday Fun is a PowerShell module I call PSCode. The module contains a few functions for encoding and decoding text. Now, before you get too excited, these won't stand up to NSA scrutiny or even anyone proficient at code breaking, although I'd like to think I've made it a little challenging. Of course, the whole point of these Friday Fun posts is to learn a little PowerShell as well.<\/p>\n<p>The basic encoding premise I'm using is a relative simple transposition. That is, replace S with E. But how to figure out what character substitute? There needs to be some \"key\" so that the message can later be decoded. My approach was to turn plaintext into its corresponding series of [CHAR] objects. I could have simply used the ToCharArray() method, but PowerShell is too helpful and I wanted to get the underlying integer value. My approach was to process each character of the word with a For statement.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nfor ($i=0;$i -lt $word.length;$i++) {<br \/>\n   $x=$word[$i]<br \/>\n   #get the current numeric value<br \/>\n   $x=[char]::ConvertToUtf32(\"$x\",0)<br \/>\n<\/code><\/p>\n<p>The trick here is to use the ConvertToUTF32() method of the [CHAR] class to get the integer value. From the console this is what it looks like:<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS S:\\> [char]::ConvertToUtf32(\"P\",0)<br \/>\n80<br \/>\n<\/code><\/p>\n<p>My substitution idea is to get another character based on some calculated offset. I could have simply said always get the current value plus 5. But then frequency analysis would break that pretty quickly. So my default algorithm, which can be modified via a parameter, is to calculate an offset based on the length of the current word. I take this value and perform a modulo operation using pi, adding 3 to it and rounding it to an integer. This guarantees an offset.<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS S:\\> $word=\"PowerShell\"<br \/>\nPS S:\\> $word.length%[math]::pi<br \/>\n0.575222039230621<br \/>\nPS S:\\> $word.length%[math]::pi+3<br \/>\n3.57522203923062<br \/>\nPS S:\\> [int]$off=$word.length%[math]::pi+3<br \/>\nPS S:\\> $off<br \/>\n4<br \/>\n<\/code><\/p>\n<p>This value is added to the [CHAR] value of the current letter. So in my example, the new value is 84. To get the corresponding character I invoke the ConvertFromUtf32() method and write the result to the pipeline.<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS S:\\> [char]::ConvertFromUtf32(84)<br \/>\nT<br \/>\n<\/code><\/p>\n<p>Because the offset is based on a per word length, it varies throughout the plaintext. Thus each word would require a separate analysis, at least for most unclassified civilians. Anyway, the last piece is to use the -Join operator to assemble each character back into a word and write it to the pipeline. Here's the ConvertTo-PSCode function.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nFunction ConvertTo-PSCode {<br \/>\n<#\ncomment based help\n#><\/p>\n<p>[cmdletbinding()]<\/p>\n<p>Param(<br \/>\n[Parameter(Position=0,Mandatory=$True,ValueFromPipeline=$True)]<br \/>\n[AllowEmptyString()]<br \/>\n[AllowNull()]<br \/>\n[string[]]$Text,<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[scriptblock]$Scriptblock={($word.length%[math]::pi)+3}<br \/>\n)<\/p>\n<p>Begin {<br \/>\n    #an array to hold encoded output<br \/>\n    Write-Verbose \"Starting $($myinvocation.mycommand)\"<br \/>\n    $Out=@()<br \/>\n}<br \/>\nProcess {<\/p>\n<p>#split text into words and lines<br \/>\nforeach ($line in $text) {<br \/>\n$newLine=\"\"<br \/>\n  Write-Verbose \"Processing line: $line\"<br \/>\n    $NewLine+= foreach ($word in ($line.Split())) {<br \/>\n        write-Verbose \" Processing word: $word\"<br \/>\n        $chars = for ($i=0;$i -lt $word.length;$i++) {<br \/>\n            $x=$word[$i]<br \/>\n            #get the current numeric value<br \/>\n            $x=[char]::ConvertToUtf32(\"$x\",0)<br \/>\n            #Calculate an offset. The default is the length of the<br \/>\n            #word modulo pi rounded to an integer plus 3<br \/>\n            [int]$off=&$Scriptblock<br \/>\n            Write-Verbose \"Using an offset of $off based on length $($word.length)\"<br \/>\n            [int]$y=$x+$off<br \/>\n            #get the new value<br \/>\n            [char]::ConvertFromUtf32($y)<br \/>\n        } #for<br \/>\n        #write the new \"word\" to the pipeline<br \/>\n        $NewWord=$chars -join \"\"<br \/>\n        $NewWord<br \/>\n    } #foreach word<br \/>\n   $Out+=$NewLine<br \/>\n} #foreach line<br \/>\n} #end process<br \/>\nEnd {<br \/>\n    Write $Out<br \/>\n}<br \/>\n} #function<br \/>\n<\/code><\/p>\n<p>The function takes plaintext as a parameter or you can pipe to it. The offset algorithm is passed as a scriptblock. You can pass your own which I'll show you in a moment. <\/p>\n<p><code lang=\"DOS\"><br \/>\nPS S:\\> convertto-pscode \"I am the walrus\"<br \/>\nM fr znk }grx{y<br \/>\nPS S:\\> \"I am the walrus\" | convertto-pscode<br \/>\nM fr znk }grx{y<br \/>\n<\/code><\/p>\n<p>To decode the text, I can use the same technique. Except instead of adding the offset, I subtract it.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\n#rounded to an integer<br \/>\n[int]$off=&$Scriptblock<br \/>\nWrite-Verbose \"Using an offset of $off based on length $($word.length)\"<br \/>\n[int]$y=$x-$off<br \/>\n#get the new value<br \/>\n[char]::ConvertFromUtf32($y)<br \/>\n<\/code><\/p>\n<p>The ConvertFrom-PSCode function also takes pipelined input which makes it very easy to test.<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS S:\\> \"I am the walrus\" | convertto-pscode | convertfrom-pscode<br \/>\nI am the walrus<br \/>\n<\/code><\/p>\n<p>If I decide to use a different algorithm, I need to specify it for both functions. Depending on your formula you might end up with non-alpha characters.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-1-300x101.png\" alt=\"\" title=\"pscode-1\" width=\"300\" height=\"101\" class=\"aligncenter size-medium wp-image-2452\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-1-300x101.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-1-1024x345.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-1.png 1137w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>As you can see in the figure the offset is the length of the word plus 5 which makes for some interesting code. Now for the really cool part. Because the convert functions write to the pipeline you can direct them to Out-File to save your results. Let's say I have a simple script.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\n#requires -version 2.0<\/p>\n<p>[cmdletbinding()]<\/p>\n<p>Param(<br \/>\n[Parameter(Position=0)]<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[string]$name=\"m*\"<br \/>\n)<\/p>\n<p>write-host \"$(Get-Date) Starting a sample script\" -ForegroundColor Green<br \/>\nWrite-verbose \"getting services where name = $name\"<br \/>\nGet-service -name $name | where {$_.status -eq \"running\"}<\/p>\n<p>write-host \"$(Get-Date) Ending a sample script\" -ForegroundColor Green<br \/>\n<\/code><\/p>\n<p>I'll encode the script using the defaults.<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS S:\\> cat c:\\work\\abc.txt | convertto-pscode | out-file c:\\work\\secretscript.txt<br \/>\nPS S:\\> cat C:\\work\\secretscript.txt<br \/>\n)xkw{oxky 2{jwxnts 846<\/p>\n<p>_gqhpixfmrhmrk,-a<\/p>\n<p>Vgxgs.<br \/>\n_Teveqixiv,TswmxmsrA4-a<br \/>\n_ZepmhexiRsxRyppsvIqtx},-a<br \/>\n`xywnslb)sfrjB'r\/'<br \/>\n-<\/p>\n<p>{vmxi1lswx (*.Mkz3Jgzk\/ Xyfwynsl e ygsvrk wgvmtx& 0IruhjurxqgFroru Lwjjs<br \/>\nZulwh0yhuervh 'ljyynsl xjw{nhjx |mjwj reqi A *tgsk(<br \/>\nLjy2xjw{nhj 2sfrj )sfrj \u0080 |mjwj (c2wxexyw 3kw &vyrrmrk&\u0081<\/p>\n<p>{vmxi1lswx (*.Mkz3Jgzk\/ Ktjotm e ygsvrk wgvmtx& 0IruhjurxqgFroru Lwjjs<br \/>\n<\/code><\/p>\n<p>What I thought would be extra fun would be a way to run this encoded script. So I wrote Invoke-PSCode.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nFunction Invoke-PSCode {<\/p>\n<p><#\ncomment based help\n#><\/p>\n<p>[cmdletbinding()]<br \/>\nParam(<br \/>\n[Parameter(Position=0,Mandatory=$True,ValueFromPipeline=$True)]<br \/>\n[AllowEmptyString()]<br \/>\n[AllowNull()]<br \/>\n[string[]]$Text,<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[scriptblock]$Scriptblock={($word.length%[math]::pi)+3},<br \/>\n[hashtable]$Arguments<br \/>\n)<br \/>\nBegin {<br \/>\n    Write-Verbose \"Starting $($myinvocation.mycommand)\"<br \/>\n    #define an empty string to hold the contents of the decoded command<br \/>\n    $a=\"\"<br \/>\n}<br \/>\nProcess {<br \/>\n    foreach ($item in $text) {<br \/>\n    #add each decoded line to the variable plus a line return<br \/>\n    Write-Verbose \"Decoding $item\"<br \/>\n     $a+=\"{0} `n\" -f (ConvertFrom-PSCode -Text $item -Scriptblock $Scriptblock)<br \/>\n    }<br \/>\n } #process<\/p>\n<p>End {<br \/>\n    Write-Verbose \"Running command\"<br \/>\n        #create a scriptblock<br \/>\n    $myCommand=$ExecutionContext.InvokeCommand.NewScriptBlock($a)<br \/>\n    #splat the arguments to the script block<br \/>\n    &$myCommand @Arguments<br \/>\n    Write-Verbose \"Ending $($myinvocation.mycommand)\"<br \/>\n}<br \/>\n} #end function<br \/>\n<\/code><\/p>\n<p>The function takes each line of code and decodes it. Each decoded line is saved as part of a long string which is eventually turned into a scriptblock and executed. To pass parameters to the secret command, which you have to know in advance, Invoke-PSCode takes a hashtable of parameters and splats them to the scriptblock.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-2-300x129.png\" alt=\"\" title=\"pscode-2\" width=\"300\" height=\"129\" class=\"aligncenter size-medium wp-image-2453\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-2-300x129.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-2-1024x443.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-2.png 1137w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>I haven't tested this against all possible types of scripts and code samples but I thought it was fun. <\/p>\n<p>The last little function in the module is something to quickly take a string and write its reverse to the pipeline. The business part is basically a single line that gets each character from a string in reverse order and writes it to the pipeline. But using the -join operator puts it all back together. <\/p>\n<p><code lang=\"DOS\"><br \/>\nPS S:\\> $item=\"PowerShell is fun!\"<br \/>\nPS S:\\> -join $(for ($i=$item.length;$i -ge 0;$i--) {$item[$i]})<br \/>\n!nuf si llehSrewoP<br \/>\n<\/code><\/p>\n<p>The For loop starts at the length and counts down to zero. The rest of the function is merely a wrapper to this core command.<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS S:\\> \"I am the walrus\" | ConvertTo-ReverseString<br \/>\nsurlaw eht ma I<br \/>\nPS S:\\> \"I am the walrus\" | ConvertTo-ReverseString | convertto-Reversestring<br \/>\nI am the walrus<br \/>\n<\/code><\/p>\n<p>I suppose if I wanted I could even combine encoding and reversal.<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS S:\\> $x = \"PowerShell is fun for walruses.\" | ConvertTo-ReverseString | ConvertTo-PSCode<br \/>\nPS S:\\> $x<br \/>\n4yky{xrg} xul t{l xn ppilWvi{sT<br \/>\nPS S:\\> $x | ConvertFrom-PSCode | ConvertTo-ReverseString<br \/>\nPowerShell is fun for walruses.<br \/>\n<\/code><\/p>\n<p>Although I'd better not forget the order!<\/p>\n<p>So have some fun with this and maybe learn something new about PowerShell. Download <a href='http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/PSCode.psm1_.txt' _target='_blank'>PSCode.psm1<\/a>. This is a module so you'll need to put it in a folder called PSCode in your modules directory or be sure to specify the full path when you import it.<\/p>\n<p><em>Ymtxj }nu luxmkz yt yixovz gxk juuskj yt xkvkgz ymjnw {svo<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m a big fan of codes, ciphers and secret messages. I obviously am a big PowerShell fan as well. So why not mash these things together? Today&#8217;s Friday Fun is a PowerShell module I call PSCode. The module contains a few functions for encoding and decoding text. Now, before you get too excited, these won&#8217;t&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[271,4],"tags":[568,396,534,234],"class_list":["post-2450","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell","tag-friday-fun","tag-join","tag-powershell","tag-strings"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun PowerShell Crypto &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun PowerShell Crypto &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I&#039;m a big fan of codes, ciphers and secret messages. I obviously am a big PowerShell fan as well. So why not mash these things together? Today&#039;s Friday Fun is a PowerShell module I call PSCode. The module contains a few functions for encoding and decoding text. Now, before you get too excited, these won&#039;t...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2012-07-20T14:35:12+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-1-300x101.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun PowerShell Crypto\",\"datePublished\":\"2012-07-20T14:35:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/\"},\"wordCount\":808,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/07\\\/pscode-1-300x101.png\",\"keywords\":[\"Friday Fun\",\"join\",\"PowerShell\",\"strings\"],\"articleSection\":[\"Friday Fun\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/\",\"name\":\"Friday Fun PowerShell Crypto &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/07\\\/pscode-1-300x101.png\",\"datePublished\":\"2012-07-20T14:35:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/07\\\/pscode-1.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/07\\\/pscode-1.png\",\"width\":\"1137\",\"height\":\"384\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2450\\\/friday-fun-powershell-crypto\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun PowerShell Crypto\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Friday Fun PowerShell Crypto &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun PowerShell Crypto &#8226; The Lonely Administrator","og_description":"I'm a big fan of codes, ciphers and secret messages. I obviously am a big PowerShell fan as well. So why not mash these things together? Today's Friday Fun is a PowerShell module I call PSCode. The module contains a few functions for encoding and decoding text. Now, before you get too excited, these won't...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/","og_site_name":"The Lonely Administrator","article_published_time":"2012-07-20T14:35:12+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-1-300x101.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun PowerShell Crypto","datePublished":"2012-07-20T14:35:12+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/"},"wordCount":808,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-1-300x101.png","keywords":["Friday Fun","join","PowerShell","strings"],"articleSection":["Friday Fun","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/","name":"Friday Fun PowerShell Crypto &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-1-300x101.png","datePublished":"2012-07-20T14:35:12+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-1.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/pscode-1.png","width":"1137","height":"384"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun PowerShell Crypto"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1584,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1584\/friday-fun-add-scripting-signing-to-the-ise\/","url_meta":{"origin":2450,"position":0},"title":"Friday Fun Add Scripting Signing to the ISE","author":"Jeffery Hicks","date":"August 5, 2011","format":false,"excerpt":"Today's fun involves adding a menu item to the PowerShell ISE to make it easy to sign your scripts. I'm not going to go into the details about getting and installing a code signing certificate. I also assume you only have one installed. You can get this certificate by seasrching\u2026","rel":"","context":"In &quot;PowerShell ISE&quot;","block_context":{"text":"PowerShell ISE","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2962,"url":"https:\/\/jdhitsolutions.com\/blog\/friday-fun\/2962\/friday-fun-powershell-commands-by-noun\/","url_meta":{"origin":2450,"position":1},"title":"Friday Fun PowerShell Commands by Noun","author":"Jeffery Hicks","date":"April 19, 2013","format":false,"excerpt":"One of PowerShell's greatest strength's is discoverability. Once you know how, it is very easy to discover what \u00a0you can do with PowerShell and how. One reason this works is because PowerShell commands follow a consistent verb-noun naming convention. With this in mind, you can see all of the commands\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"get-command-noun-01","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/04\/get-command-noun-01-1024x577.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/04\/get-command-noun-01-1024x577.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/04\/get-command-noun-01-1024x577.png?resize=525%2C300 1.5x"},"classes":[]},{"id":4011,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4011\/friday-fun-a-popup-alternative\/","url_meta":{"origin":2450,"position":2},"title":"Friday Fun &#8211; A Popup Alternative","author":"Jeffery Hicks","date":"September 12, 2014","format":false,"excerpt":"In the past I've written and presented about different ways to add graphical elements to your PowerShell scripts that don't rely on Windows Forms or WPF. There's nothing wrong with those techniques, but they certainly require some expertise and depending on your situation may be overkill. So let's have some\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"windowpane-thumbnail","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/09\/windowpane-thumbnail.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4061,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4061\/friday-fun-lets-play-a-game\/","url_meta":{"origin":2450,"position":3},"title":"Friday Fun &#8211; Let&#8217;s Play a Game","author":"Jeffery Hicks","date":"October 3, 2014","format":false,"excerpt":"Today is going to be a lot of fun. A few years ago, back when we were still running PowerShell 2.0 everywhere, I created a module to run a Bingo game in a PowerShell session. I primarily wrote the module as a learning tool for beginners wanting to know more\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"BingoCard-small","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/BingoCard-small.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4169,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4169\/friday-fun-updated-ise-scripting-geek-module\/","url_meta":{"origin":2450,"position":4},"title":"Friday Fun: Updated ISE Scripting Geek Module","author":"Jeffery Hicks","date":"January 9, 2015","format":false,"excerpt":"A few years ago I published a module with a number of functions and enhancements for the PowerShell ISE. This ISEScriptingGeek module has remained popular over the last few years. But I wrote it for PowerShell v2. I have also come up with a number of new additions to the\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"geek","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/01\/geek-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4923,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/4923\/friday-fun-tweaking-the-powershell-ise\/","url_meta":{"origin":2450,"position":5},"title":"Friday Fun: Tweaking the PowerShell ISE","author":"Jeffery Hicks","date":"February 19, 2016","format":false,"excerpt":"Today's fun is still PowerShell related, but instead of something in the console, we'll have some fun with the PowerShell ISE. One of the things I love about the PowerShell ISE is that you can customize it and extend it.\u00a0 My ISE Scripting Geek project is an example.\u00a0 But today\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-12.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=2450"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2450\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}