#include-once #cs ; Change Log =================================================================================================== 2012-11-13 - Ron Version: 1.0.0 Initital 2015-01-10 - Ron Version: 1.0.1 Fixed - Rots 1-4, 6-12, 14-17, 19-25 Added - 3rd param for decode on the Rots 1-4, 6-12, 14-17, 19-25 =================================================================================================== #ce #cs Available ciphers: Rot1 thru Rot25 and Rot47 Definitions taken from: http://www.mobilefish.com/services/rot13/rot13.php ROT1-ROT4, ROT6-ROT17 and ROT19-ROT25 - Transforms only letters. Each letter is shifted N places: For example ROT1 (N=1): abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ becomes: bcdefghijklmnopqrstuvwxyzaBCDEFGHIJKLMNOPQRSTUVWXYZA ---- ROT5 - Transforms only numbers. Each number is shifted 5 places: 0123456789 becomes: 5678901234 ---- ROT13 - Transforms only letters. Each letter is shifted 13 places: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ becomes: nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM ---- ROT18 - Transforms only letters and numbers. abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 becomes: nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM5678901234 ---- ROT47 - Transforms ASCII characters 33-126. Each character is shifted 47 places: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ becomes: PQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO ---- #ce ;=================================================================================================== ; ; Function Name....: _cipher_Rot($s_data [, $iRotType = 13 [, $bDecode = False]]) ; Description......: cipher char rotation Rot:1-25, 47 ; Parameter(s).....: ; $sData: String to encode/decode ; $iRotType: [Default = 13]; integer 1-18, 25, or 47 ; $bDecode: [Default = False]; For rot 1-4, 6-12, 14-17, 19-25 only ; Return Value(s)..: ; Success...: Encoded or Decoded string ; Failure...: Empty string ; Error.....: ; 1. Empty String ; 2. StringToASCIIArray() failed ; 3. Passed wrong type of $iRotType ; Requirement(s)...: N/A ; Author(s)........: SmOke_N (Ron Nielsen) Ron.SMACKThatApp@gmail.com ; Modified.........: N/A ; Comment(s).......: Tested with AutoIt 3.3.6.1/3.3.12.0 ; Example(s).......: See example output in comment fields within the include file ; ;=================================================================================================== Func _cipher_Rot($sData, $iRotType = 13, $bDecode = False) If Not StringLen($sData) Then Return SetError(1, 0, "") Local $aStr = StringToASCIIArray($sData) If @error Then Return SetError(2, 0, "") $iRotType = Int($iRotType) Switch $iRotType Case 1 To 4, 6 To 12, 14 To 17, 19 To 25 ; alpha only For $idat = 0 To UBound($aStr) - 1 If Not $bDecode Then Switch $aStr[$idat] Case 65 To 90 $aStr[$idat] += $iRotType If $aStr[$idat] > 90 Then $aStr[$idat] = ($aStr[$idat] - 90) + 64 EndIf Case 97 To 122 $aStr[$idat] += $iRotType If $aStr[$idat] > 122 Then $aStr[$idat] = ($aStr[$idat] - 122) + 96 EndIf EndSwitch Else Switch $aStr[$idat] Case 65 To 90 $aStr[$idat] -= $iRotType If $aStr[$idat] < 65 Then $aStr[$idat] = 91 - (65 - $aStr[$idat]) EndIf Case 97 To 122 $aStr[$idat] -= $iRotType If $aStr[$idat] < 97 Then $aStr[$idat] = 123 - (97 - $aStr[$idat]) EndIf EndSwitch EndIf Next Case 5 ;numbers only For $idat = 0 To UBound($aStr) - 1 Switch $aStr[$idat] Case 48 To 52 $aStr[$idat] += 5 Case 53 To 57 $aStr[$idat] -= 5 EndSwitch Next Case 13 ;alpha only For $idat = 0 To UBound($aStr) - 1 Switch $aStr[$idat] Case 65 To 90 $aStr[$idat] = (($aStr[$idat] + $iRotType) < 91 ? _ $aStr[$idat] + $iRotType : $aStr[$idat] - $iRotType) Case 97 To 122 $aStr[$idat] = (($aStr[$idat] + $iRotType) < 123 ? _ $aStr[$idat] + $iRotType : $aStr[$idat] - $iRotType) EndSwitch Next Case 18 ;alpha/numeric only $iRotType = 13 For $idat = 0 To UBound($aStr) - 1 Switch $aStr[$idat] Case 48 To 52 $aStr[$idat] += 5 Case 53 To 57 $aStr[$idat] -= 5 Case 65 To 90 $aStr[$idat] = (($aStr[$idat] + $iRotType) < 91 ? _ $aStr[$idat] + $iRotType : $aStr[$idat] - $iRotType) Case 97 To 122 $aStr[$idat] = (($aStr[$idat] + $iRotType) < 123 ? _ $aStr[$idat] + $iRotType : $aStr[$idat] - $iRotType) EndSwitch Next Case 47 ;all ascii chars For $idat = 0 To UBound($aStr) - 1 If ($aStr[$idat] > 32 And $aStr[$idat] < 127) Then $aStr[$idat] = (($aStr[$idat] + $iRotType < 127) ? _ $aStr[$idat] + $iRotType : $aStr[$idat] - $iRotType) EndIf Next Case Else Return SetError(3, 0, "") EndSwitch Return StringFromASCIIArray($aStr) EndFunc ;==>_cipher_Rot