Skip to content

Instantly share code, notes, and snippets.

@chillitom
Last active January 2, 2016 17:09
Show Gist options
  • Save chillitom/8335042 to your computer and use it in GitHub Desktop.
Save chillitom/8335042 to your computer and use it in GitHub Desktop.
Powershell Rot47 implementation.. for when Rot13 just isn't secure enough.
function Rot47 { param ([string] $in)
$table = @{}
for ($i = 0; $i -lt 94; $i++) {
$table.Add(
"!`"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_``abcdefghijklmnopqrstuvwxyz{|}~"[$i],
"PQRSTUVWXYZ[\]^_``abcdefghijklmnopqrstuvwxyz{|}~!`"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO"[$i])
}
$out = New-Object System.Text.StringBuilder
$in.ToCharArray() | %{
$char = if ($table.ContainsKey($_)) {$table[$_]} else {$_}
$out.Append($char) | Out-Null
}
$out.ToString()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment