Closed hi5 closed 9 years ago
Additionally, the input isn't properly sanitized before being RegEx'd. If the input contains \E
it'll break
How about this?
MsgBox % Rot47("Hello World #123") "`nw6==@ (@C=5 R``ab"
MsgBox % Rot47("The Quick Brown Fox Jumps Over The Lazy Dog.") "`n`%96 ""F:4< qC@H? u@I yF>AD ~G6C `%96 {2KJ s@8]"
; adapted from http://langref.org/fantom+java+scala/strings/reversing-a-string/simple-substitution-cipher
; from decimal 33 '!' through 126 '~', 94
Rot47(string)
{
Loop Parse, string
{
c := Asc(A_LoopField)
c += (c >= Asc("!") && c <= Asc("O") ? 47 : (c >= Asc("P") && c <= Asc("~") ? -47 : 0))
s .= Chr(c)
}
Return s
}
; by Raccoon July-2009
; http://rosettacode.org/wiki/Rot-13#AutoHotkey
Rot13(string)
{
Loop, Parse, string
{
c := asc(A_LoopField)
if (c >= 97) && (c <= 109) || (c >= 65) && (c <= 77)
c += 13
else if (c >= 110) && (c <= 122) || (c >= 78) && (c <= 90)
c -= 13
s .= Chr(c)
}
Return s
}
Added in, implemented the rot5 and rot18. Thanks :+1:
derRaphael posted rotx (rot5, 13 and 47) here http://www.autohotkey.com/board/topic/57125-rotx-feat-rot5-rot13-and-rot47/
But for me only 5 & 13 work - the 47 fails with lowercase input so it transforms the H from Hello but leaves ello intact - or is just me?
String is: Hello World #123 ROT13 returns: Uryyb Jbeyq #123 ROT47 should return: w6==@ (@C=5 R`ab