Sign in to follow this  
Followers 0
ezzetabi

Rot13 Udf

2 posts in this topic

Here a nice and easy way to quickly use ROT13 in any of your scripts.

just copy this code at the end of the source and call it with

Rot13("Message that need a ROT13 codification")

Returns = the message codificated.

E.G.

$f = Rot13("I go home")

MsgBox(0,"","I go home codified is " & $f)

Func Rot13($input)

Local $c, $roted, $char, $asciiN

$roted = ""
For $c = 1 to StringLen($input)
   $char = String(StringMid($input,$c,1))
   $asciiN = Asc($char)
   Select
      Case (65 <= $asciiN AND $asciiN <= 90)
         If $asciiN <= 77 Then
            $asciiN = $asciiN + 13
         Else
            $asciiN = $asciiN - 13
         EndIf         
      Case (97 <= $asciiN AND $asciiN <= 122)
         If $asciiN <= 109 Then
            $asciiN = $asciiN + 13
         Else
            $asciiN = $asciiN - 13
         EndIf
      Case (48 <= $asciiN AND $asciiN <= 57)
         If $asciiN <= 52 Then
            $asciiN = $asciiN + 5
         Else
            $asciiN = $asciiN - 5
         EndIf
   EndSelect
   $roted = $roted & Chr($asciiN)
Next

Return $roted
EndFunc

Share this post


Link to post
Share on other sites



Just for fun, here's a completely different (probably not as efficient) implementation:

MsgBox(4096,"Test", rot13(rot13("This should be the same!")) )
Exit

Func rot13($input)
  $output = ''
  $alphabet = "abcdefghijklmnopqrstuvwxyzabcdefghijklm"
  $alphabet = $alphabet & StringUpper($alphabet)
  $alphabet = $alphabet & " 0123456789   56789012345   "

  For $i = 1 to StringLen($input)
    $pos = StringInStr($alphabet, StringMid($input,$i,1) ,1)
    If $pos <> 0 Then
      $output = $output & StringMid($alphabet, $pos+13, 1)
    Else
      $output = $output & StringMid($input,$i,1)
    EndIf
  Next

  Return $output
EndFunc

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0