Jump to content
Alek

Enigma

Recommended Posts

well, i dont know much about enigma but i gave it a shot, so far it can only encrypt :) im still not sure how to make it decrypt (yet).

what i know about enigma is only the stuff i found on Wikipedia so please report back if there is something wrong with it.

i found it by random googleing :P

it creates new totaly random rollers (the things that creates the encryption) every time you start the script.

not sure if this was smart idea.

Edit: move the "rollers" to the correct part of the script (i think)

started working on the decrypting script, dosent work yet :blink:

#include <GUIConstants.au3>
Global $Roller[5][3]
            ;[number_of_Rollers][2]
            ;[$n][0] = then input|output alphabet
            ;[$n][1] = roller status. (how many times it has bin moved)
            ;[$n][2] = inputbox handle for the gui.

For $x = 0 To UBound($Roller,1)-1
    $Roller[$x][0] = _GenerateRandomalphabet() & "|" & _GenerateRandomalphabet()
    $Roller[$x][1] = 0
Next

$Form1 = GUICreate("", 395, 286, 193, 125)
$Edit1 = GUICtrlCreateInput("", 5, 25, 385, 89,$ES_MULTILINE)
$Label1 = GUICtrlCreateLabel("Input", 5, 5, 28, 17, $SS_SUNKEN)
$Edit2 = GUICtrlCreateInput("", 5, 190, 385, 89, $ES_MULTILINE)
$Label2 = GUICtrlCreateLabel("Output", 5, 170, 36, 17, $SS_SUNKEN)
$Button1 = GUICtrlCreateButton("Encrypt", 5, 120, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Reset Rollers", 85, 120, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Decrypt", 165, 120, 75, 25, 0)
GUICtrlSetState(-1,$GUI_DISABLE)
For $x = 0 To UBound($Roller,1)-1
    $Roller[$x][2] = GUICtrlCreateInput("1",(22*$x)+5,147,20,20)
Next

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetState($Button1,$GUI_DISABLE)
            $Text = GUICtrlRead($Edit1)
            $New_Text = _Enigma($Text,0)
            
            GUICtrlSetData($Edit2,$New_Text)
            For $x = 0 To UBound($Roller,1)-1
                GUICtrlSetData($Roller[$x][2],$Roller[$x][1]+1)
            Next
            
            GUICtrlSetState($Button1,$GUI_ENABLE)
        Case $Button2
            
            ;Reset the rollers, bad idea if we are going to decrypt it xD
            For $x = 0 To UBound($Roller,1)-1
                GUICtrlSetData($Roller[$x][2],$Roller[$x][1]+1)
                $Roller[$x][1] = 0
            Next
        Case $Button3
            GUICtrlSetState($Button3,$GUI_DISABLE)
            $Text = GUICtrlRead($Edit2)
            $New_Text = _Enigma($Text,1)
            
            GUICtrlSetState($Button3,$GUI_ENABLE)
            GUICtrlSetData($Edit1,$New_Text)
            For $x = 0 To UBound($Roller,1)-1
                GUICtrlSetData($Roller[$x][2],$Roller[$x][1]+1)
            Next
    EndSwitch
WEnd

Func _GenerateRandomalphabet()
    ;Thought it whould easyest to create a random alphabet, please tell me if it shouldent be random.
    Local $Return = ""
    For $x = 1 To 26
        Do
            $Random = Random(97,122,1)
        Until Not StringInStr($Return,Chr($Random))
        $Return &= Chr($Random)
    Next
    Return $Return
EndFunc

Func _Enigma($_String,$_Way=0) ;0 = encrypt, 1 = decrypt (not made yet xD)
    Local $Output_String = ""
    Switch $_Way
        Case 0
            
            ;write to the console what we are encrypting.
            ConsoleWrite("Encrypting: " & $_String & @CRLF)
            Do
                ;Get the chr we want to encrypt.
                $String = StringLeft($_String,1)
                
                ;Encrypt the shit.
                For $x = 0 To UBound($Roller,1)-1
                    
                    ;Split the input|output
                    $Split = StringSplit($Roller[$x][0],"|")
                    
                    ;find the chr on the input side + the amount of scrolling the rollers has done.
                    $Input = StringInStr($Split[1],$string)+$Roller[$x][1]
                    
                    ;check if the input is right, if not then correct it.
                    If $Input > 26 Then $Input -= 26
                    
                    ;Get the output chr.
                    $Output = StringSplit($Split[2],"")
                    
                    If $Input > UBound($Output)-1 Then MsgBox(0,"",$Input & " Wtf??" & @CRLF & StringLen($Split[1]))
                    
                    ;Set the string to the output chr to make the chr move on to the next roller.
                    ConsoleWrite("[" & $x+1 & "]: " & $string & "->" & $Output[$Input] & " ")
                    
                    ;Set the string so we can use it on the next roller.
                    $String = $Output[$Input]
                    
                Next
                    
                If $Roller[0][1] = 26 Then
                    For $x = 1 to UBound($Roller,1)-1
                        If $Roller[$x-1][1] = 26 Then
                            $Roller[$x][1] += 1
                            $Roller[$x-1][1] = 0
                        EndIf
                    Next
                Else
                    $Roller[0][1] += 1
                EndIf
                ;Put together the output string.
                $Output_String &= $String
                
                ;Create a new line in the console.
                ConsoleWrite(@CRLF)
                
                ;trim the _String to get the next chr.
                $_String = StringTrimLeft($_String,1)
            Until $_String = ""
            ConsoleWrite(@CRLF)
        Case 1
            
            ;Write to console what we are decrypting.
            ConsoleWrite("Decrypting: " & $_String & @CRLF)
            
            ;enter a do unil $_string = "" loop
            Do
                
                ;Get the text we want to decrypt
                $String = StringRight($_String,1)
                
                ;Loop trought all the rollers
                For $x = UBound($Roller,1)-1 to 0 Step -1
                    
                    ;Split the input|output of that roller. 
                    $Split = StringSplit($Roller[$x][0],"|")
                    
                    ;Get the input on the roller.
                    $Input = StringInStr($Split[2],$string) - $Roller[$x][1]
                    
                    ;Splitt the output, remeber we have changed the way the code enters and leaves the roller.
                    $Output = StringSplit($Split[1],"")
                    
                    If $Input < 0 Then $Input = 26-($Input*-1)
                    
                    ConsoleWrite("[" & $x+1 & "]: " & $string & "->" & $Output[$Input] & " ")
                    
                    $String = $Output[$Input]
                Next
                
                If $Roller[0][1] = 0 Then
                    For $x = 1 to UBound($Roller,1)-1
                        If $Roller[$x-1][1] = 0 Then
                            $Roller[$x][1] -= 1
                            $Roller[$x-1][1] = 26
                        EndIf
                    Next
                Else
                    $Roller[0][1] -= 1
                EndIf
                
                $Output_String &= $string
                ConsoleWrite(@CRLF)
                $_String = StringTrimRight($_String,1)
            Until $_String = ""
            
            ConsoleWrite(@CRLF)
    EndSwitch
    
    ;return the encrypted data.
    Return StringUpper($Output_String)
EndFunc
Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Share this post


Link to post
Share on other sites

hey i had a question...its probably a stupid question but w/e ummm.... is it possible to create a script for a playfair cipher? if so could u help me get started? i know how to write one and use one by hand its just i dont know how to make it into a script

Share this post


Link to post
Share on other sites

hey i had a question...its probably a stupid question but w/e ummm.... is it possible to create a script for a playfair cipher? if so could u help me get started? i know how to write one and use one by hand its just i dont know how to make it into a script

Go along to the helpfile, or if your to lazy then go to rentacoder.com. This is not a place to request scripts!

Share this post


Link to post
Share on other sites

I did a attempt in 2016 to make a Enigma machine. I'm not coding much anymore since some years so i thought i'd better release what i did come up. Its working code. Encrypts and Decrypts. Optional word space can be turned of and on. Optional SHA256 encode the already Enigma encrypted code. There's still a small error somewhere but i don't have time or do want to fix that. Anyway perhaps someone can use this code and make it better or just play with it for fun.

 

;===============================================================================
; Author: 48Pluto 23 januari 2016
; Program Name: My_Enigma.exe
; National Geographic Code Breakers [https://www.youtube.com/watch?v=JOL6J13hHyU]
; The Complexity of CODES - History Documentary Films [https://www.youtube.com/watch?v=sMQqK6NmRyc]
;===============================================================================
#include <array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <Date.au3>
#include <Crypt.au3>


; Options
Opt ( 'MustDeclareVars', 1 )
Opt ( 'GUIOnEventMode', 1 )

; Constants
Const $WindowTitle = " Encryptie Machine  -  Versie 1.02  - (c) Pluut 7-02-2016"
Const $SuperEncrypt = False
Const $DEBUG = False

; Declare and Initialize GUI Variables
Global $mainUiHeight = 420
Global $mainUiWidth = 800
Global $TOPMARGIN = 10                                              ; gets adjusted troughout the program
Global $LEFTMARGIN = 10                                             ; left margin
Global $RIGHTMARGIN = $mainUiWidth - (2 * $LEFTMARGIN)              ; right margin
Local $BUTTON_HEIGHT = 25
Local $BUTTON_WIDTH = 90
Local $TEXT_BOX_HEIGHT = 150

; Salt Input
Local $mod1 = mod ( _WeekNumberISO (), 3 )
Local $mod2 = mod ( $mod1, 3 ) + $mod1 * 2
;Local $day = @MDAY                         ; code is valid for today only
Local $day = _WeekNumberISO ()              ; code is valid for this week only
Local $sSuperEncryptKey = "until" & $day    ; code is valid for this week only
Local $iAlgorithm = $CALG_AES_256

; Global Settings
Global $aRotorInit [9] = [ 0,0,$day,0,0,0,0,0,0 ]   ; SLT
Global $aRotor = $aRotorInit
Global $aWiringRotor_0_1 [26]
Global $aWiringRotor_1_2 [26]
Global $aWiringRotor_2_3 [26]
Global $aWiringRotor_3_4 [26]
Global $aWiringRotor_4_5 [26]
Global $aWiringRotor_5_6 [26]
Global $aWiringRotor_6_7 [26]
Global $aWiringRotor_7_8 [26]
Global $aWiringRotor_8_9 [26]

; User Interface
Local $hGUI = GUICreate ( $WindowTitle, $mainUiWidth, $mainUiHeight, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN )
GUISetBkColor ( 0xD8D8D8 )
GUISetIcon( @ScriptDir & "\au3script_v9.ico" )

; Create Input Text Box Label
Local $GUIStatusMessage = GUICtrlCreateLabel ( "", $LEFTMARGIN, $TOPMARGIN, $mainUiWidth - $LEFTMARGIN, 20 )
GUICtrlSetFont ( $GUIStatusMessage, 11, 590, 0, "Helvetica" )
GUICtrlSetData ( $GUIStatusMessage, StringLeft("Voer de tekst in:", 60 ) )

; Create Output Text Box Label
Local $GUIStatusMessage = GUICtrlCreateLabel ( "", $LEFTMARGIN, $TOPMARGIN + $TEXT_BOX_HEIGHT + 35, $mainUiWidth - $LEFTMARGIN, 20 )
GUICtrlSetFont ( $GUIStatusMessage, 11, 590, 0, "Helvetica" )
GUICtrlSetData ( $GUIStatusMessage, StringLeft("Resultaat:", 60 ) )

; Create Text Boxes
Local $TXT_INPUT = GUICtrlCreateInput ( "", $LEFTMARGIN, $TOPMARGIN + 25, $RIGHTMARGIN, $TEXT_BOX_HEIGHT, $ES_MULTILINE )
Local $TXT_OUTPUT = GUICtrlCreateInput ( "", $LEFTMARGIN, $TOPMARGIN + $TEXT_BOX_HEIGHT + 60, $RIGHTMARGIN, $TEXT_BOX_HEIGHT, $ES_MULTILINE )

; Create Buttons
Local $BTN_ENCRYPT = GUICtrlCreateButton ( "Encrypt", $LEFTMARGIN + $BUTTON_WIDTH * 4 + 100, $mainUiheight - 35, $BUTTON_WIDTH, $BUTTON_HEIGHT )
Local $BTN_DECRYPT = GUICtrlCreateButton ( "Decrypt", $LEFTMARGIN + $BUTTON_WIDTH * 5 + 120, $mainUiheight - 35, $BUTTON_WIDTH, $BUTTON_HEIGHT )
Local $BTN_CLOSEPROGRAM = GUICtrlCreateButton ( "Afsluiten", $RIGHTMARGIN - $BUTTON_WIDTH + $LEFTMARGIN, $mainUiheight - 35, $BUTTON_WIDTH, $BUTTON_HEIGHT )

; Set the GUI Events
GUICtrlSetOnEvent ( $BTN_CLOSEPROGRAM, "_GUI_closeOnEvent" )
GUICtrlSetOnEvent ( $BTN_ENCRYPT, "_GUI_Encrypt" )
GUICtrlSetOnEvent ( $BTN_DECRYPT, "_GUI_Decrypt" )

; Show the GUI
GUISetState ( @SW_SHOW )

; Init
Local $iCount = 0
InitialiseMachineSettings ( )

While 1
    Sleep ( 200 )
Wend  ;==> Main Loop()

; ==================================
; Func _GUI_Encrypt ( )
; ==================================
Func _GUI_Encrypt ( )
    $aRotor = $aRotorInit                           ; Reset the Rotor Wheels
    Local $sSecret = GUICtrlRead ( $TXT_INPUT )
    Local $sEncoded = Encode ( $sSecret, "encode" )         ; Encode
    $sEncoded = StringReplace ( $sEncoded, "|", "" )
    If $DEBUG = True Then ConsoleWrite ( "Encoded: " & $sEncoded & @CRLF )
    If $SuperEncrypt = True Then
        $sEncoded = _Crypt_EncryptData ( $sEncoded, $sSuperEncryptKey, $iAlgorithm )
        $sEncoded = BinaryToString ( $sEncoded )
    EndIf
    ControlSetText ( "", "", $TXT_OUTPUT, $sEncoded )
EndFunc   ;==> _GUI_Encrypt

; ==================================
; Func _GUI_Decrypt ( )
; ==================================
Func _GUI_Decrypt ( )
    $aRotor = $aRotorInit                           ; Reset the Rotor Wheels
    Local $sSecret = GUICtrlRead ( $TXT_INPUT )
    If $SuperEncrypt = True Then
        $sSecret = _Crypt_DecryptData ( $sSecret, $sSuperEncryptKey, $iAlgorithm )
        $sSecret = BinaryToString ( $sSecret )
    EndIf
    Local $sDecoded = Encode ( $sSecret, "decode" )         ; Decode
    $sDecoded = StringReplace ( $sDecoded, "|", "" )
    If $DEBUG = True Then ConsoleWrite ( "Decoded: " & $sDecoded & @CRLF )
    ControlSetText ( "", "", $TXT_OUTPUT, $sDecoded )
EndFunc   ;==> _GUI_Decrypt

; ==================================
; Func Encode ( code )
; ==================================
Func Encode ( $sCode, $action )
    Local $iPosFound, $sEncodeChar
    If $action <> "encode" And $action <> "decode" Then
        MsgBox ( 6, "Error", "Function Encode called with wrong arguments" )
        Return
    EndIf
    Local $aCode = StringSplit ( $sCode, "" )
    _ArrayDelete ( $aCode, 0 )

    For $n = 0 to UBound ( $aCode ) - 1
        If $action = "encode" Then $sEncodeChar = CodeScramble ( $aCode [$n], "encode" ) ; 1
        If $action = "decode" Then $sEncodeChar = CodeScramble ( $aCode [$n], "decode" ) ; 1
        $aCode [$n] = $sEncodeChar
    Next
    Return ( _ArrayToString ( $aCode ) )
EndFunc   ;==> Encode

; ==================================
; Func CodeScramble ( character, encode/decode )
; ==================================
Func CodeScramble ( $sChar, $action )
    Local $aWireCombo ; Contains 0=index, 1=start value, 2=end value
    Local $retValue

    If $sChar = " " Then    ; Verwijder de spaties uit de encryptie / decryptie [maakt lezen moeilijker maar reversed engineering ook]
        ;RotorRotate ( )    ; wil je wel spaties uncomment deze regel   (stap 1)
        Return ""           ; wil je wel spaties dan return " "         (laatste stap)
    EndIf

    If $action = "encode" Then
        $retValue = PassRotor ( $sChar, "encode" )
        Return $retValue
    ElseIf $action = "decode" Then
        $retValue = PassRotor ( $sChar, "decode" )
        Return $retValue
    Else
        MsgBox ( 6, "Error", "Function CodeScramble called with wrong arguments" )
    EndIf

EndFunc

; ==================================
; Func PassRotor ( )
; ==================================
Func PassRotor ( $sChar, $action )
    Local $iSecretRotorNumber, $aWireCombo
    If $action <> "encode" And $action <> "decode" Then
        MsgBox ( 6, "Error", "Function CodeScramble called with wrong arguments" )
        Return
    EndIf

    $iSecretRotorNumber = RotorRotate ()
    ConsoleWrite ( $iSecretRotorNumber & " " )
    Select
        Case $iSecretRotorNumber = 14 Or $iSecretRotorNumber = 3
            if $action = "encode" Then
                For $i = 0 to UBound ( $aWiringRotor_0_1 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_0_1 [$i], "," )
                    If $aWireCombo [1] = $sChar Then Return $aWireCombo [2]
                Next
            Else
                For $i = 0 to UBound ( $aWiringRotor_0_1 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_0_1 [$i], "," )
                    If $aWireCombo [2] = $sChar Then Return $aWireCombo [1]
                Next
            EndIf
        Case $iSecretRotorNumber = 13 Or $iSecretRotorNumber = 4
            if $action = "encode" Then
                For $i = 0 to UBound ( $aWiringRotor_1_2 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_1_2 [$i], "," )
                    If $aWireCombo [1] = $sChar Then Return $aWireCombo [2]
                Next
            Else
                For $i = 0 to UBound ( $aWiringRotor_1_2 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_1_2 [$i], "," )
                    If $aWireCombo [2] = $sChar Then Return $aWireCombo [1]
                Next
            EndIf
        Case $iSecretRotorNumber = 12 Or $iSecretRotorNumber = 2
            if $action = "encode" Then
                For $i = 0 to UBound ( $aWiringRotor_2_3 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_2_3 [$i], "," )
                    If $aWireCombo [1] = $sChar Then Return $aWireCombo [2]
                Next
            Else
                For $i = 0 to UBound ( $aWiringRotor_2_3 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_2_3 [$i], "," )
                    If $aWireCombo [2] = $sChar Then Return $aWireCombo [1]
                Next
            EndIf
        Case $iSecretRotorNumber = 11 Or $iSecretRotorNumber = 6
            if $action = "encode" Then
                For $i = 0 to UBound ( $aWiringRotor_3_4 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_3_4 [$i], "," )
                    If $aWireCombo [1] = $sChar Then Return $aWireCombo [2]
                Next
            Else
                For $i = 0 to UBound ( $aWiringRotor_3_4 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_3_4 [$i], "," )
                    If $aWireCombo [2] = $sChar Then Return $aWireCombo [1]
                Next
            EndIf
        Case $iSecretRotorNumber = 10 Or $iSecretRotorNumber = 7
            if $action = "encode" Then
                For $i = 0 to UBound ( $aWiringRotor_4_5 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_4_5 [$i], "," )
                    If $aWireCombo [1] = $sChar Then Return $aWireCombo [2]
                Next
            Else
                For $i = 0 to UBound ( $aWiringRotor_4_5 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_4_5 [$i], "," )
                    If $aWireCombo [2] = $sChar Then Return $aWireCombo [1]
                Next
            EndIf
        Case $iSecretRotorNumber = 9 Or $iSecretRotorNumber = 16
            if $action = "encode" Then
                For $i = 0 to UBound ( $aWiringRotor_5_6 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_5_6 [$i], "," )
                    If $aWireCombo [1] = $sChar Then Return $aWireCombo [2]
                Next
            Else
                For $i = 0 to UBound ( $aWiringRotor_5_6 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_5_6 [$i], "," )
                    If $aWireCombo [2] = $sChar Then Return $aWireCombo [1]
                Next
            EndIf
        Case $iSecretRotorNumber = 15 Or $iSecretRotorNumber = 5
            if $action = "encode" Then
                For $i = 0 to UBound ( $aWiringRotor_8_9 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_8_9 [$i], "," )
                    If $aWireCombo [1] = $sChar Then Return $aWireCombo [2]
                Next
            Else
                For $i = 0 to UBound ( $aWiringRotor_8_9 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_8_9 [$i], "," )
                    If $aWireCombo [2] = $sChar Then Return $aWireCombo [1]
                Next
            EndIf
        Case $iSecretRotorNumber = 8 Or $iSecretRotorNumber = 1
            if $action = "encode" Then
                For $i = 0 to UBound ( $aWiringRotor_6_7 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_6_7 [$i], "," )
                    If $aWireCombo [1] = $sChar Then Return $aWireCombo [2]
                Next
            Else
                For $i = 0 to UBound ( $aWiringRotor_6_7 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_6_7 [$i], "," )
                    If $aWireCombo [2] = $sChar Then Return $aWireCombo [1]
                Next
            EndIf
        Case Else
            if $action = "encode" Then
                For $i = 0 to UBound ( $aWiringRotor_7_8 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_7_8 [$i], "," )
                    If $aWireCombo [1] = $sChar Then Return $aWireCombo [2]
                Next
            Else
                For $i = 0 to UBound ( $aWiringRotor_7_8 ) - 1
                    $aWireCombo = StringSplit ( $aWiringRotor_7_8 [$i], "," )
                    If $aWireCombo [2] = $sChar Then Return $aWireCombo [1]
                Next
            EndIf
    EndSelect

EndFunc   ;==> PassRotor

; ==================================
; Func RotorRotate ( )
; ==================================
Func RotorRotate ( )
    Local $RotorNum = 0

    $aRotor [0] += 1
    If $aRotor [0] > 2 Then
        $aRotor [1] += 1
        $aRotor [0] -= 1
        $RotorNum = 1
    EndIf
    If $aRotor [1] > 2 Then
        $aRotor [2] += 1
        $aRotor [1] -= 1
        $RotorNum = 2
    EndIf
    If $aRotor [2] > 2 Then
        $aRotor [3] += 1
        $aRotor [2] -= 1
        $RotorNum = 3
    EndIf
    If $aRotor [3] > 2 Then
        $aRotor [4] += 1
        $aRotor [3] -= 1
        $RotorNum = 4
    EndIf
    If $aRotor [4] > 2 Then
        $aRotor [5] += 1
        $aRotor [4] -= 1
        $RotorNum = 5
    EndIf
    If $aRotor [5] > 2 Then
        $aRotor [6] += 1
        $aRotor [5] -= 1
        $RotorNum = 6
    EndIf
    If $aRotor [6] > 2 Then
        $aRotor [6] -= 1
        $aRotor [0] = 0
        $aRotor [1] = 0
        $aRotor [2] = 2
        $aRotor [3] = 0
        $aRotor [4] = 0
        $aRotor [5] = 0
        $aRotor [6] = 0
        $aRotor = $aRotorInit                           ; Reset the Rotor Wheels
    EndIf

    ; _ArrayDisplay ( $aRotor )
    $iCount =  ( $aRotor [0] + $aRotor [1] + $aRotor [2] + $aRotor [3] + $aRotor [4] + $aRotor [5] + $aRotor [6] ) ; / ( $aRotor[$RotorNum] )
    $iCount = int ( $iCount, 1 )
    Return ( $iCount )
EndFunc   ;==> RotorRotate

; ==================================
; Func InitialiseMachineSettings ( )
; ==================================
Func InitialiseMachineSettings ( )

    $aWiringRotor_0_1 [0] = "A,Z"   ; Rotor 0 to 1
    $aWiringRotor_0_1 [1] = "B,K"
    $aWiringRotor_0_1 [2] = "C,M"
    $aWiringRotor_0_1 [3] = "D,F"
    $aWiringRotor_0_1 [4] = "E,L"
    $aWiringRotor_0_1 [5] = "F,G"
    $aWiringRotor_0_1 [6] = "G,D"
    $aWiringRotor_0_1 [7] = "H,Q"
    $aWiringRotor_0_1 [8] = "I,V"
    $aWiringRotor_0_1 [9] = "J,E"
    $aWiringRotor_0_1 [10] ="K,N"
    $aWiringRotor_0_1 [11] ="L,T"
    $aWiringRotor_0_1 [12] ="M,O"
    $aWiringRotor_0_1 [13] ="N,W"
    $aWiringRotor_0_1 [14] ="O,Y"
    $aWiringRotor_0_1 [15] ="P,H"
    $aWiringRotor_0_1 [16] ="Q,X"
    $aWiringRotor_0_1 [17] ="R,U"
    $aWiringRotor_0_1 [18] ="S,S"
    $aWiringRotor_0_1 [19] ="T,P"
    $aWiringRotor_0_1 [20] ="U,A"
    $aWiringRotor_0_1 [21] ="V,I"
    $aWiringRotor_0_1 [22] ="W,B"
    $aWiringRotor_0_1 [23] ="X,R"
    $aWiringRotor_0_1 [24] ="Y,C"
    $aWiringRotor_0_1 [25] ="Z,J"

    $aWiringRotor_1_2 [0] = "A,P"   ; Rotor 1 to 2
    $aWiringRotor_1_2 [1] = "B,J"
    $aWiringRotor_1_2 [2] = "C,D"
    $aWiringRotor_1_2 [3] = "D,K"
    $aWiringRotor_1_2 [4] = "E,S"
    $aWiringRotor_1_2 [5] = "F,I"
    $aWiringRotor_1_2 [6] = "G,R"
    $aWiringRotor_1_2 [7] = "H,U"
    $aWiringRotor_1_2 [8] = "I,X"
    $aWiringRotor_1_2 [9] = "J,B"
    $aWiringRotor_1_2 [10] ="K,L"
    $aWiringRotor_1_2 [11] ="L,H"
    $aWiringRotor_1_2 [12] ="M,W"
    $aWiringRotor_1_2 [13] ="N,T"
    $aWiringRotor_1_2 [14] ="O,M"
    $aWiringRotor_1_2 [15] ="P,C"
    $aWiringRotor_1_2 [16] ="Q,Q"
    $aWiringRotor_1_2 [17] ="R,G"
    $aWiringRotor_1_2 [18] ="S,Z"
    $aWiringRotor_1_2 [19] ="T,N"
    $aWiringRotor_1_2 [20] ="U,A"
    $aWiringRotor_1_2 [21] ="V,Y"
    $aWiringRotor_1_2 [22] ="W,F"
    $aWiringRotor_1_2 [23] ="X,V"
    $aWiringRotor_1_2 [24] ="Y,O"
    $aWiringRotor_1_2 [25] ="Z,E"

    $aWiringRotor_2_3 [0] = "A,Y"   ; Rotor 2 to 3
    $aWiringRotor_2_3 [1] = "B,D"
    $aWiringRotor_2_3 [2] = "C,F"
    $aWiringRotor_2_3 [3] = "D,H"
    $aWiringRotor_2_3 [4] = "E,J"
    $aWiringRotor_2_3 [5] = "F,L"
    $aWiringRotor_2_3 [6] = "G,C"
    $aWiringRotor_2_3 [7] = "H,P"
    $aWiringRotor_2_3 [8] = "I,R"
    $aWiringRotor_2_3 [9] = "J,T"
    $aWiringRotor_2_3 [10] ="K,X"
    $aWiringRotor_2_3 [11] ="L,V"
    $aWiringRotor_2_3 [12] ="M,N"
    $aWiringRotor_2_3 [13] ="N,Z"
    $aWiringRotor_2_3 [14] ="O,B"
    $aWiringRotor_2_3 [15] ="P,E"
    $aWiringRotor_2_3 [16] ="Q,I"
    $aWiringRotor_2_3 [17] ="R,W"
    $aWiringRotor_2_3 [18] ="S,G"
    $aWiringRotor_2_3 [19] ="T,A"
    $aWiringRotor_2_3 [20] ="U,K"
    $aWiringRotor_2_3 [21] ="V,M"
    $aWiringRotor_2_3 [22] ="W,U"
    $aWiringRotor_2_3 [23] ="X,S"
    $aWiringRotor_2_3 [24] ="Y,Q"
    $aWiringRotor_2_3 [25] ="Z,O"

    $aWiringRotor_3_4 [0] = "A,K"   ; Rotor 3 to 4
    $aWiringRotor_3_4 [1] = "B,W"
    $aWiringRotor_3_4 [2] = "C,M"
    $aWiringRotor_3_4 [3] = "D,C"
    $aWiringRotor_3_4 [4] = "E,D"
    $aWiringRotor_3_4 [5] = "F,B"
    $aWiringRotor_3_4 [6] = "G,G"
    $aWiringRotor_3_4 [7] = "H,T"
    $aWiringRotor_3_4 [8] = "I,F"
    $aWiringRotor_3_4 [9] = "J,N"
    $aWiringRotor_3_4 [10] ="K,L"
    $aWiringRotor_3_4 [11] ="L,X"
    $aWiringRotor_3_4 [12] ="M,H"
    $aWiringRotor_3_4 [13] ="N,R"
    $aWiringRotor_3_4 [14] ="O,I"
    $aWiringRotor_3_4 [15] ="P,U"
    $aWiringRotor_3_4 [16] ="Q,Q"
    $aWiringRotor_3_4 [17] ="R,Y"
    $aWiringRotor_3_4 [18] ="S,A"
    $aWiringRotor_3_4 [19] ="T,J"
    $aWiringRotor_3_4 [20] ="U,Z"
    $aWiringRotor_3_4 [21] ="V,P"
    $aWiringRotor_3_4 [22] ="W,V"
    $aWiringRotor_3_4 [23] ="X,O"
    $aWiringRotor_3_4 [24] ="Y,S"
    $aWiringRotor_3_4 [25] ="Z,E"

    $aWiringRotor_4_5 [0] = "A,K"   ; Rotor 4 to 5
    $aWiringRotor_4_5 [1] = "B,X"
    $aWiringRotor_4_5 [2] = "C,E"
    $aWiringRotor_4_5 [3] = "D,F"
    $aWiringRotor_4_5 [4] = "E,O"
    $aWiringRotor_4_5 [5] = "F,Q"
    $aWiringRotor_4_5 [6] = "G,J"
    $aWiringRotor_4_5 [7] = "H,M"
    $aWiringRotor_4_5 [8] = "I,W"
    $aWiringRotor_4_5 [9] = "J,A"
    $aWiringRotor_4_5 [10] ="K,C"
    $aWiringRotor_4_5 [11] ="L,L"
    $aWiringRotor_4_5 [12] ="M,H"
    $aWiringRotor_4_5 [13] ="N,D"
    $aWiringRotor_4_5 [14] ="O,N"
    $aWiringRotor_4_5 [15] ="P,B"
    $aWiringRotor_4_5 [16] ="Q,S"
    $aWiringRotor_4_5 [17] ="R,U"
    $aWiringRotor_4_5 [18] ="S,Y"
    $aWiringRotor_4_5 [19] ="T,T"
    $aWiringRotor_4_5 [20] ="U,I"
    $aWiringRotor_4_5 [21] ="V,G"
    $aWiringRotor_4_5 [22] ="W,R"
    $aWiringRotor_4_5 [23] ="X,P"
    $aWiringRotor_4_5 [24] ="Y,Z"
    $aWiringRotor_4_5 [25] ="Z,V"

    $aWiringRotor_5_6 [0] = "A,S"   ; Rotor 5 to 6
    $aWiringRotor_5_6 [1] = "B,G"
    $aWiringRotor_5_6 [2] = "C,X"
    $aWiringRotor_5_6 [3] = "D,L"
    $aWiringRotor_5_6 [4] = "E,B"
    $aWiringRotor_5_6 [5] = "F,A"
    $aWiringRotor_5_6 [6] = "G,T"
    $aWiringRotor_5_6 [7] = "H,U"
    $aWiringRotor_5_6 [8] = "I,M"
    $aWiringRotor_5_6 [9] = "J,V"
    $aWiringRotor_5_6 [10] ="K,P"
    $aWiringRotor_5_6 [11] ="L,Q"
    $aWiringRotor_5_6 [12] ="M,W"
    $aWiringRotor_5_6 [13] ="N,N"
    $aWiringRotor_5_6 [14] ="O,J"
    $aWiringRotor_5_6 [15] ="P,K"
    $aWiringRotor_5_6 [16] ="Q,R"
    $aWiringRotor_5_6 [17] ="R,O"
    $aWiringRotor_5_6 [18] ="S,F"
    $aWiringRotor_5_6 [19] ="T,Y"
    $aWiringRotor_5_6 [20] ="U,Z"
    $aWiringRotor_5_6 [21] ="V,H"
    $aWiringRotor_5_6 [22] ="W,I"
    $aWiringRotor_5_6 [23] ="X,C"
    $aWiringRotor_5_6 [24] ="Y,D"
    $aWiringRotor_5_6 [25] ="Z,E"

    $aWiringRotor_6_7 [0] = "A,V"   ; Rotor 7 to 8
    $aWiringRotor_6_7 [1] = "B,W"
    $aWiringRotor_6_7 [2] = "C,T"
    $aWiringRotor_6_7 [3] = "D,J"
    $aWiringRotor_6_7 [4] = "E,Y"
    $aWiringRotor_6_7 [5] = "F,Q"
    $aWiringRotor_6_7 [6] = "G,E"
    $aWiringRotor_6_7 [7] = "H,Z"
    $aWiringRotor_6_7 [8] = "I,F"
    $aWiringRotor_6_7 [9] = "J,C"
    $aWiringRotor_6_7 [10] ="K,G"
    $aWiringRotor_6_7 [11] ="L,H"
    $aWiringRotor_6_7 [12] ="M,I"
    $aWiringRotor_6_7 [13] ="N,A"
    $aWiringRotor_6_7 [14] ="O,K"
    $aWiringRotor_6_7 [15] ="P,U"
    $aWiringRotor_6_7 [16] ="Q,L"
    $aWiringRotor_6_7 [17] ="R,M"
    $aWiringRotor_6_7 [18] ="S,S"
    $aWiringRotor_6_7 [19] ="T,B"
    $aWiringRotor_6_7 [20] ="U,D"
    $aWiringRotor_6_7 [21] ="V,N"
    $aWiringRotor_6_7 [22] ="W,X"
    $aWiringRotor_6_7 [23] ="X,P"
    $aWiringRotor_6_7 [24] ="Y,R"
    $aWiringRotor_6_7 [25] ="Z,O"

    $aWiringRotor_7_8 [0] = "A,E"   ; Rotor 8 to 9
    $aWiringRotor_7_8 [1] = "B,G"
    $aWiringRotor_7_8 [2] = "C,M"
    $aWiringRotor_7_8 [3] = "D,R"
    $aWiringRotor_7_8 [4] = "E,I"
    $aWiringRotor_7_8 [5] = "F,J"
    $aWiringRotor_7_8 [6] = "G,Q"
    $aWiringRotor_7_8 [7] = "H,A"
    $aWiringRotor_7_8 [8] = "I,N"
    $aWiringRotor_7_8 [9] = "J,O"
    $aWiringRotor_7_8 [10] ="K,W"
    $aWiringRotor_7_8 [11] ="L,X"
    $aWiringRotor_7_8 [12] ="M,Y"
    $aWiringRotor_7_8 [13] ="N,Z"
    $aWiringRotor_7_8 [14] ="O,U"
    $aWiringRotor_7_8 [15] ="P,V"
    $aWiringRotor_7_8 [16] ="Q,H"
    $aWiringRotor_7_8 [17] ="R,K"
    $aWiringRotor_7_8 [18] ="S,C"
    $aWiringRotor_7_8 [19] ="T,D"
    $aWiringRotor_7_8 [20] ="U,L"
    $aWiringRotor_7_8 [21] ="V,P"
    $aWiringRotor_7_8 [22] ="W,A"
    $aWiringRotor_7_8 [23] ="X,F"
    $aWiringRotor_7_8 [24] ="Y,S"
    $aWiringRotor_7_8 [25] ="Z,T"

    $aWiringRotor_8_9 [0] = "A,M"   ; Rotor 9 to 10
    $aWiringRotor_8_9 [1] = "B,N"
    $aWiringRotor_8_9 [2] = "C,G"
    $aWiringRotor_8_9 [3] = "D,B"
    $aWiringRotor_8_9 [4] = "E,C"
    $aWiringRotor_8_9 [5] = "F,D"
    $aWiringRotor_8_9 [6] = "G,H"
    $aWiringRotor_8_9 [7] = "H,I"
    $aWiringRotor_8_9 [8] = "I,Z"
    $aWiringRotor_8_9 [9] = "J,J"
    $aWiringRotor_8_9 [10] ="K,C"
    $aWiringRotor_8_9 [11] ="L,W"
    $aWiringRotor_8_9 [12] ="M,X"
    $aWiringRotor_8_9 [13] ="N,K"
    $aWiringRotor_8_9 [14] ="O,L"
    $aWiringRotor_8_9 [15] ="P,O"
    $aWiringRotor_8_9 [16] ="Q,P"
    $aWiringRotor_8_9 [17] ="R,A"
    $aWiringRotor_8_9 [18] ="S,Q"
    $aWiringRotor_8_9 [19] ="T,R"
    $aWiringRotor_8_9 [20] ="U,S"
    $aWiringRotor_8_9 [21] ="V,T"
    $aWiringRotor_8_9 [22] ="W,E"
    $aWiringRotor_8_9 [23] ="X,F"
    $aWiringRotor_8_9 [24] ="Y,U"
    $aWiringRotor_8_9 [25] ="Z,V"

EndFunc   ;==> InitialiseMachineSettings

; ==================================
; Func _GUI_closeOnEvent ( )
; ==================================
Func _GUI_closeOnEvent()
    GUIDelete()
    Exit 0
EndFunc   ;==> _GUI_closeOnEvent

 

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

×
×
  • Create New...