-
Notifications
You must be signed in to change notification settings - Fork 0
/
atbash.au3
59 lines (56 loc) · 1.66 KB
/
atbash.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
; ====================================================
; =========== Atbash String Converter CLI ============
; ====================================================
; AutoIt version: 3.3.12.0
; Language: English
; Author: Pedro F. Albanese
; Modified: -
;
; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------
#NoTrayIcon
If $CmdLineRaw == "" Then
ConsoleWrite("Atbash ALBANESE Research Lab " & Chr(184) & " 2016" & @CRLF) ;
ConsoleWrite("Usage: " & @ScriptName & " <string/file.ext>" & @CRLF) ;
Else
If $CmdLine[1] == '-' Then
Local $sOutput
While True
$sOutput &= ConsoleRead()
If @error Then ExitLoop
Sleep(25)
WEnd
$full = StringReplace($sOutput, @CRLF, '')
$full = StringReplace($full, @LF, '')
ConsoleWrite(atbash($full))
ElseIf $CmdLine[1] <> '-' Then
If FileExists($CmdLine[1]) Then
$full = FileRead($CmdLine[1])
Else
$full = $CmdLine[1]
EndIf
ConsoleWrite(atbash($full))
EndIf
EndIf
Exit
Func atbash($text)
$letters = StringSplit(StringReplace($text, " ", ""), "")
$max = $letters[0] + 1
Dim $convert[$max]
Dim $output[$max]
$atbash = ""
For $i = 1 To $letters[0] Step 1
$convert[$i] = Asc($letters[$i])
If $convert[$i] > 64 And $convert[$i] < 91 Then
$output[$i] = 91 - $convert[$i] + 64
ElseIf $convert[$i] > 96 And $convert[$i] < 123 Then
$output[$i] = 123 - $convert[$i] + 96
Else
$output[$i] = $convert[$i]
EndIf
$output[$i] = Chr($output[$i])
$atbash = $atbash & $output[$i]
Next
Return $atbash
EndFunc ;==>atbash