Jump to content
bahjat

Problem with my program

Recommended Posts

bahjat

Why does my program not work?
It works perfectly when you input the ASCII key 5 but if you input anything else like real words it doesn't seem to operate at all and i can't seem to get the HEX to ascii to work either.
Please explain i am so upset with this program

#include-Once
#include <MsgBoxConstants.au3>
#include <Crypt.au3>
;~ $timer = TimerInit()
;~ $timer = TimerInit()
;~  MsgBox(0, "AES Encrypted data", _EncryptionProcess("6bc1bee22e409f96e93d7e117393172a", "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", 256, 1) & " Time:" & TimerDiff($timer))





;****Input your message here and the key size ****


Textinput()

Func Textinput()
    ; Places the input box in the top left corner displaying the characters as they
    ; are typed.
    Global $data = InputBox("Enter your message", "Please enter your message in ASCII", "5", ""); takes in the input from the user
    MsgBox (0, "your input is", $data)
    Global $keyvalue = InputBox("Enter your key", "Key size please", "20 30 40", ""); takes in the input from the user
    MsgBox (0, "Your Key is", $keyvalue)
    Global $keysize = InputBox("enter the key size", "Key sizes can be 128,192 and 256", "128", ""); takes in the input from the user
    MsgBox (0, "your input is", $keysize)
EndFunc





;*****ASCII to Hexadecimal conversion*****

Global $V2 = $data

$ASCIItoHEX = AscToHex($V2)
MsgBox(0,"Ascii to Hex converstion" ,$ASCIItoHEX)
Func AscToHex($varaible2)

    Global $Turn=""
    For $variable1 = 1 To StringLen($varaible2)
        If StringLen(Hex(Asc(StringMid($varaible2, $variable1,1)),2)) = 1 Then
            $Turn &=  "5" & Hex(Asc(StringMid($varaible2, $variable1, 1)))
        Else
            $Turn &=  Hex(Asc(StringMid($varaible2, $variable1, 1)),2)
        EndIf

        If $variable1 <> StringLen($varaible2) Then $Turn &=  " "
    Next
    Return $Turn
endFunc









; the input data is stored in $V2
; the output data is stored in  $turn










;$turn

$DataToBeEncrypted=_EncryptionProcess($Turn, "2b7e151628aed2a6abf7158809cf4f3c", $keysize, 1)
MsgBox(0, "Encrypted data", $DataToBeEncrypted)
$DataToBeDecrypted =_EncryptionProcess($DataToBeEncrypted, "2b7e151628aed2a6abf7158809cf4f3c" , $keysize, 0)
MsgBox(0, "Decrypted data", $DataToBeDecrypted)


Func _EncryptionProcess($InputText, $GVKey, $Key = $keysize, $EncryptionNumber = 1)
    ;$GVKey takes the encryption that you want to be processed and puts it in Var

    ;$GVKey is the size of the key that you want to use, the $Key is what it will default too
;~     ;$EncryptionNumber deicdes if you want to encrypt it or not
;~         If $Key <> 128 And $Key <> 192 And $Key <> 256 Then
;~                 SetError(1, 0, 0)
;~         ElseIf StringLen($InputText) <> 32 Then
;~                 SetError(2, 0, 0)
;~         ElseIf StringLen($GVKey) <> 32 And $Key = 128 Then
;~                 SetError(3, 0, 0)
;~         ElseIf StringLen($GVKey) <> 48 And $Key = 192 Then
;~                 SetError(3, 0, 0)
;~         ElseIf StringLen($GVKey) <> 64 And $Key = 256 Then
;~                 SetError(3, 0, 0)
;~         ElseIf $EncryptionNumber <> 1 And $EncryptionNumber <> 0 Then
;~                 SetError(4, 0, 0)
;~         EndIf



        Local $LVOutput[16]
        Local $LVInput[16]
        Local $InputHex[32]
        Local $SubRoundKeyStep[240]
        Local $LV2 = 1
        Local $CheckValue

        Local $NumberOfRounds

        Local $LGVKey



        $LGVKey = $Key / 32 ;32 hexadecimals from 128 bits input
        $NumberOfRounds = $LGVKey + 6
;converts the hexadecimal to Decimal
        For $Var1 = 0 To $LGVKey * 4 - 1
                $InputHex[$Var1] = Dec(StringMid($GVKey, $LV2, 2))
                $LV2 = $LV2+ 2
        Next

        $LV2 = 1
        For $Var1 = 0 To 15
                $LVInput[$Var1] = Dec(StringMid($InputText, $LV2, 2))
                $LV2 = $LV2 + 2
        Next

        $SubRoundKeyStep = __TheyKeyExpansionStep($InputHex, $NumberOfRounds, $LGVKey)

        If $EncryptionNumber = 1 Then ;Encrypt
                $LVOutput = __Algorithm($LVInput, $SubRoundKeyStep, $NumberOfRounds) ; in this part you are going through the Algorithm function
                ;line 259 or approximate
        ElseIf $EncryptionNumber = 0 Then ; decrypt
                $LVOutput = __DecryptionProcess($LVInput, $SubRoundKeyStep, $NumberOfRounds)
        EndIf



        For $Var1 = 0 To 15
                $CheckValue &= $LVOutput[$Var1]
        Next

        Return $CheckValue

;converts the hexadecimal to decimal
EndFunc





Func __ValueOfTheSubstitutionBox($SubstitutionBoxNumber)
        Local $SubsitutionBoxOutput[256] = [0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75, 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF, 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8, 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73, 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB, 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08, 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A, 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16]
        Return $SubsitutionBoxOutput[Dec(Hex($SubstitutionBoxNumber, 2))]; making sure it is in hex a decimal allowing the language to read it
        ;it takes the input then creating a local Var and using the array of the s-box

EndFunc   ;==>__ValueOfTheSubstitutionBox





Func __TheyKeyExpansionStep($InputHex, $NumberOfRounds, $LGVKey) ;theese Vars define are defining the major parts of the things. How many rounds and how big the key needs to be
        Local $Var1
        Local $LV6
        Local $SubRoundKeyStep[240]
        Local $LV3[4]
        Local $TheRconFunction[255] = [0x8D, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36, 0x6C, 0xD8, 0xAB, 0x4D, 0x9A, 0x2F, 0x5E, 0xBC, 0x63, 0xC6, 0x97, 0x35, 0x6A, 0xD4, 0xB3, 0x7D, 0xFA, 0xEF, 0xC5, 0x91, 0x39, 0x72, 0xE4, 0xD3, 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9A, 0x2F, 0x5E, 0xBC, 0x63, 0xC6, 0x97, 0x35, 0x6A, 0xD4, 0xB3, 0x7D, 0xFA, 0xEF, 0xC5, 0x91, 0x39, 0x72, 0xE4, 0xD3, 0xBD, 0x61, 0xC2, 0x9F, 0x25, 0x4A, 0x94, 0x33, 0x66, 0xCC, 0x83, 0x1D, 0x3A, 0x74, 0xE8, 0xCB]

        For $Var1 = 0 To $LGVKey - 1
                $SubRoundKeyStep[$Var1 * 4] = $InputHex[$Var1 * 4]
                $SubRoundKeyStep[$Var1 * 4 + 1] = $InputHex[$Var1 * 4 + 1]
                $SubRoundKeyStep[$Var1 * 4 + 2] = $InputHex[$Var1 * 4 + 2]
                $SubRoundKeyStep[$Var1 * 4 + 3] = $InputHex[$Var1 * 4 + 3]
        Next
        While $Var1 < (4 * ($NumberOfRounds + 1))
                For $LV2 = 0 To 3
                        $LV3[$LV2] = $SubRoundKeyStep[($Var1 - 1) * 4 + $LV2]
                Next
                If Mod($Var1, $LGVKey) = 0 Then
                        $LV6 = $LV3[0]
                        $LV3[0] = $LV3[1]
                        $LV3[1] = $LV3[2]
                        $LV3[2] = $LV3[3]
                        $LV3[3] = $LV6
                        $LV3[0] = __ValueOfTheSubstitutionBox($LV3[0])
                        $LV3[1] = __ValueOfTheSubstitutionBox($LV3[1])
                        $LV3[2] = __ValueOfTheSubstitutionBox($LV3[2])
                        $LV3[3] = __ValueOfTheSubstitutionBox($LV3[3])
                        $LV3[0] = BitXOR($LV3[0], $TheRconFunction[$Var1 / $LGVKey])
                ElseIf $LGVKey > 6 And Mod($Var1, $LGVKey) = 4 Then
                        $LV3[0] = __ValueOfTheSubstitutionBox($LV3[0])
                        $LV3[1] = __ValueOfTheSubstitutionBox($LV3[1])
                        $LV3[2] = __ValueOfTheSubstitutionBox($LV3[2])
                        $LV3[3] = __ValueOfTheSubstitutionBox($LV3[3])
                EndIf



                $SubRoundKeyStep[$Var1 * 4 + 0] = BitXOR($SubRoundKeyStep[($Var1 - $LGVKey) * 4 + 0], $LV3[0])
                $SubRoundKeyStep[$Var1 * 4 + 1] = BitXOR($SubRoundKeyStep[($Var1 - $LGVKey) * 4 + 1], $LV3[1])
                $SubRoundKeyStep[$Var1 * 4 + 2] = BitXOR($SubRoundKeyStep[($Var1 - $LGVKey) * 4 + 2], $LV3[2])
                $SubRoundKeyStep[$Var1 * 4 + 3] = BitXOR($SubRoundKeyStep[($Var1 - $LGVKey) * 4 + 3], $LV3[3])
                $Var1 = $Var1 + 1
        WEnd

        Return $SubRoundKeyStep

EndFunc   ;==>__TheyKeyExpansionStep

Func __TheAddRoundKeyStep($LV9, $SubRoundKeyStep, $CurrentState) ; The add round key step
        For $Var1 = 0 To 3
                For $LV2 = 0 To 3
                        $CurrentState[$LV2][$Var1] = BitXOR($CurrentState[$LV2][$Var1], $SubRoundKeyStep[$LV9 * 4 * 4 + $Var1 * 4 + $LV2])
                Next
        Next
; It takes the currect state value and BitXOR it with the the round key
; the multiplication and addition process figures out what number it is
; the $LV9 Step is needed
        Return $CurrentState

EndFunc   ;==>__TheAddRoundKeyStep

Func __SubBytes($CurrentState)
        For $Var1 = 0 To 3
                For $LV2 = 0 To 3
                        $CurrentState[$Var1][$LV2] = __ValueOfTheSubstitutionBox($CurrentState[$Var1][$LV2])
                Next
        Next

        Return $CurrentState

EndFunc   ;==>__SubBytes

Func __InvSubBytes($CurrentState)
        For $Var1 = 0 To 3 ;4loops
                For $LV2 = 0 To 3
                        $CurrentState[$Var1][$LV2] = __ValueOfTheInvertSubstitutionBox($CurrentState[$Var1][$LV2]); this is calling another function which is the get S-BOX value function
                        ;the long line is this function
                Next
        Next

        Return $CurrentState

EndFunc   ;




Func __TheShiftRowStep($CurrentState) ; this is the shift row step.
                            ; $CurrentState is the input
        Local $LV3
                            ;this is the temporary Var



        $LV3 = $CurrentState[1][0]
        $CurrentState[1][0] = $CurrentState[1][1] ; As you can see the [1][0] gets moved over to [1][1] hence shfting it
        $CurrentState[1][1] = $CurrentState[1][2]
        $CurrentState[1][2] = $CurrentState[1][3]
        $CurrentState[1][3] = $LV3
        $LV3 = $CurrentState[2][0]
        $CurrentState[2][0] = $CurrentState[2][2]; it does this the correct time
        $CurrentState[2][2] = $LV3
        $LV3 = $CurrentState[2][1]
        $CurrentState[2][1] = $CurrentState[2][3]
        $CurrentState[2][3] = $LV3
        $LV3 = $CurrentState[3][0]
        $CurrentState[3][0] = $CurrentState[3][3]
        $CurrentState[3][3] = $CurrentState[3][2]
        $CurrentState[3][2] = $CurrentState[3][1]
        $CurrentState[3][1] = $LV3

        Return $CurrentState

EndFunc   ;==>__TheShiftRowStep

Func __TheInverseShiftRowSetp($CurrentState)
        Local $LV3

        $LV3 = $CurrentState[1][3]
        $CurrentState[1][3] = $CurrentState[1][2]
        $CurrentState[1][2] = $CurrentState[1][1]
        $CurrentState[1][1] = $CurrentState[1][0]
        $CurrentState[1][0] = $LV3
        $LV3 = $CurrentState[2][0]
        $CurrentState[2][0] = $CurrentState[2][2]
        $CurrentState[2][2] = $LV3
        $LV3 = $CurrentState[2][1]
        $CurrentState[2][1] = $CurrentState[2][3]
        $CurrentState[2][3] = $LV3
        $LV3 = $CurrentState[3][0]
        $CurrentState[3][0] = $CurrentState[3][1]
        $CurrentState[3][1] = $CurrentState[3][2]
        $CurrentState[3][2] = $CurrentState[3][3]
        $CurrentState[3][3] = $LV3

        Return $CurrentState

EndFunc   ;==>__TheInverseShiftRowSetp

Func __factor($LVMultiplication)
        Return BitXOR(BitShift($LVMultiplication, -1), (BitAND(BitShift($LVMultiplication, 7), 1) * 0x1B)); this function is used in the Mix Column step
        ; the 0x1B is a hexadecimal number
EndFunc   ;==>__factor
Func __Multiplication($LVMultiplication, $LVMultiplication2)
        Return BitXOR((BitAND($LVMultiplication2, 1) * $LVMultiplication), (BitAND(BitShift($LVMultiplication2, 1), 1) * __factor($LVMultiplication)), (BitAND(BitShift($LVMultiplication2, 2), 1) * __factor(__factor($LVMultiplication))), (BitAND(BitShift($LVMultiplication2, 3), 1) * __factor(__factor(__factor($LVMultiplication)))), (BitAND(BitShift($LVMultiplication2, 4), 1) * __factor(__factor(__factor(__factor($LVMultiplication))))))
EndFunc   ;==>__Multiplication
Func __TheMixColumnStep($CurrentState); the input that is used
        Local $LV5p ; your temporrary Vars

        Local $LV5
        Local $LVMixColumnT



        For $Var1 = 0 To 3; You have your 4 loops here (4 columns)
                $LVMixColumnT = $CurrentState[0][$Var1]
                $LV5p = BitXOR($CurrentState[0][$Var1], $CurrentState[1][$Var1], $CurrentState[2][$Var1], $CurrentState[3][$Var1])
                $LV5 = BitXOR($CurrentState[0][$Var1], $CurrentState[1][$Var1])
                $LV5 = __factor($LV5) ; this is calling the _Factor function
                $CurrentState[0][$Var1] = BitXOR($CurrentState[0][$Var1], BitXOR($LV5, $LV5p))
                $LV5 = BitXOR($CurrentState[1][$Var1], $CurrentState[2][$Var1])
                $LV5 = __factor($LV5)
                $CurrentState[1][$Var1] = BitXOR($CurrentState[1][$Var1], BitXOR($LV5, $LV5p))
                $LV5 = BitXOR($CurrentState[2][$Var1], $CurrentState[3][$Var1])
                $LV5 = __factor($LV5)
                $CurrentState[2][$Var1] = BitXOR($CurrentState[2][$Var1], BitXOR($LV5, $LV5p))
                $LV5 = BitXOR($CurrentState[3][$Var1], $LVMixColumnT)
                $LV5 = __factor($LV5)
                $CurrentState[3][$Var1] = BitXOR($CurrentState[3][$Var1], BitXOR($LV5, $LV5p))
        Next

        Return $CurrentState

EndFunc   ;==>__TheMixColumnStep



Func __Algorithm($LVInput, $SubRoundKeyStep, $NumberOfRounds)
    ;$NumberOfRounds states the number of rounds
    ;$SubRoundKeyStep uses the round function
    ;$LVInput is the Var for the input

        Local $LVOutput[16]
        Local $CurrentState[4][4]

        For $Var1 = 0 To 3
                For $LV2 = 0 To 3
                        $CurrentState[$LV2][$Var1] = $LVInput[$Var1 * 4 + $LV2]
                        ;This part is the 2 dimensinal array; this part is the one dimensional array
                        ; this converts the input from a 1 dimensional array to a 2 dimenasional



                Next
        Next

        $CurrentState = __TheAddRoundKeyStep(0, $SubRoundKeyStep, $CurrentState)
;the add round key step
        For $LV9 = 1 To $NumberOfRounds - 1
                $CurrentState = __SubBytes($CurrentState); these things are calling upon the functions to undergo their process in order

                $CurrentState = __TheShiftRowStep($CurrentState)
                $CurrentState = __TheMixColumnStep($CurrentState)
                $CurrentState = __TheAddRoundKeyStep($LV9, $SubRoundKeyStep, $CurrentState)
        ; the 9 rounds of the Subbytes, shiftroyws, mix columns and add round key step
        Next

        $CurrentState = __SubBytes($CurrentState)
        $CurrentState = __TheShiftRowStep($CurrentState)
        $CurrentState = __TheAddRoundKeyStep($NumberOfRounds, $SubRoundKeyStep, $CurrentState)
; this is the final round which does not include the mix column step
        For $Var1 = 0 To 3
                For $LV2 = 0 To 3
                        $LVOutput[$Var1 * 4 + $LV2] = Hex($CurrentState[$LV2][$Var1], 2)
                Next
        Next

        Return $LVOutput
EndFunc
Func __DecryptionProcess($LVInput, $SubRoundKeyStep, $NumberOfRounds)

        Local $LVOutput[16]
        Local $CurrentState[4][4]

        For $Var1 = 0 To 3
                For $LV2 = 0 To 3
                        $CurrentState[$LV2][$Var1] = $LVInput[$Var1 * 4 + $LV2]
                Next
        Next

        $CurrentState = __TheAddRoundKeyStep($NumberOfRounds, $SubRoundKeyStep, $CurrentState)

        For $LV9 = $NumberOfRounds - 1 To 1 Step -1
                $CurrentState = __TheInverseShiftRowSetp($CurrentState)
                $CurrentState = __InvSubBytes($CurrentState)
                $CurrentState = __TheAddRoundKeyStep($LV9, $SubRoundKeyStep, $CurrentState)
                $CurrentState = __InvTheMixColumnStep($CurrentState)
        Next

        $CurrentState = __TheInverseShiftRowSetp($CurrentState)
        $CurrentState = __InvSubBytes($CurrentState)
        $CurrentState = __TheAddRoundKeyStep(0, $SubRoundKeyStep, $CurrentState)

        For $Var1 = 0 To 3
                For $LV2 = 0 To 3
                        $LVOutput[$Var1 * 4 + $LV2] = Hex($CurrentState[$LV2][$Var1], 2)
                Next
        Next

        Return $LVOutput
EndFunc
Func __InvTheMixColumnStep($CurrentState)
        Local $Var1
        Local $LVMixColumn1
        Local $LVMixColumn2
        Local $LVMixColumn3
        Local $LVMixColumn4

        For $Var1 = 0 To 3
                $LVMixColumn1 = $CurrentState[0][$Var1]
                $LVMixColumn2 = $CurrentState[1][$Var1]
                $LVMixColumn3 = $CurrentState[2][$Var1]
                $LVMixColumn4 = $CurrentState[3][$Var1]

                $CurrentState[0][$Var1] = BitXOR(__Multiplication($LVMixColumn1, 0x0e), __Multiplication($LVMixColumn2, 0x0b), __Multiplication($LVMixColumn3, 0x0d), __Multiplication($LVMixColumn4, 0x09))
                $CurrentState[1][$Var1] = BitXOR(__Multiplication($LVMixColumn1, 0x09), __Multiplication($LVMixColumn2, 0x0e), __Multiplication($LVMixColumn3, 0x0b), __Multiplication($LVMixColumn4, 0x0d))
                $CurrentState[2][$Var1] = BitXOR(__Multiplication($LVMixColumn1, 0x0d), __Multiplication($LVMixColumn2, 0x09), __Multiplication($LVMixColumn3, 0x0e), __Multiplication($LVMixColumn4, 0x0b))
                $CurrentState[3][$Var1] = BitXOR(__Multiplication($LVMixColumn1, 0x0b), __Multiplication($LVMixColumn2, 0x0d), __Multiplication($LVMixColumn3, 0x09), __Multiplication($LVMixColumn4, 0x0e))
        Next

        Return $CurrentState
EndFunc

Func __ValueOfTheInvertSubstitutionBox($SubstitutionBoxNumber)
        Local $LVSubsitutionBox[256] = [0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, 0x08, 0x2E, 0xA1, 0x66, 0x28, 0x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0x3C, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D]
        Return $LVSubsitutionBox[Dec(Hex($SubstitutionBoxNumber, 2))]
EndFunc   ;==>__ValueOfTheInvertSubstitutionBox

;***** Hexadecimals to ASCII*****


$HexadecimalToASCII2 = "$DataToBeDecrypted"
$HexadecimalsToASCII = ChrH($HexadecimalToASCII2)
$Ascii2Hex = Sub($HexadecimalsToASCII)
$v5ar = Chr($HexadecimalsToASCII);char

MsgBox(0,"Hex to ASCII",$HexadecimalsToASCII)

Func ChrH($v8)

    Local $v5=""
    $A1 = StringSplit($v8, " ")
    For $count = 1 To $A1[0]
        $v5 &= Chr(Dec($A1[$count]))
    Next
    Return $v5
endFunc


Func Sub($v8)

    Local $v9=""
    For $count = 1 To StringLen($v8)
        If StringLen(Hex(Asc(StringMid($v8, $count, 1)),2)) = 1 Then
            $v9 &=  "0" & Hex(Asc(StringMid($v8, $count, 1)))
        Else
            $v9 &=  Hex(Asc(StringMid($v8, $count, 1)),2)
        EndIf
        If $count <> StringLen($v8) Then $v9 &=  " "
    Next
    Return $v9
endFunc

;*****HEXADECIMAL to ASCII*****

 

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
MikahS

Instead of using a quote to fill with code, use the code tool.

Example:

Global Enum $test = "test" ; test

P.S. You can edit your posts on the bottom of each post with the Edit button.

Edited by MikahS
M23

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
JLogan3o13

So you want us to go through several hundred lines of code, with nothing more to go on than "it's broke"? How about a little more information, such as the error you're getting when you try to run it. If it is simply hanging up, you can put the following at the top of the screen to help you figure out where it is failing:

Opt("TrayIconDebug", 1)

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Melba23

MikahS,

Please stop suggesting people use the [ code ] tags - BB codes are not necessarily honoured by the new editor.  It is now recommended to use the editor "code" button.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
bahjat

So you want us to go through several hundred lines of code, with nothing more to go on than "it's broke"? How about a little more information, such as the error you're getting when you try to run it. If it is simply hanging up, you can put the following at the top of the screen to help you figure out where it is failing:

Opt("TrayIconDebug", 1)

 

​The problem arises when the **ASCII to Hex*** and the ****INPUT your text**** functions are inserted. If you are to run the program without these (in the code below) and encrypt 5552 the encryption and the decryption process function correctly  hence i think the problem is in the two functions before. 

#include-Once
#include <MsgBoxConstants.au3>
#include <Crypt.au3>


$DataToBeEncrypted=_EncryptionProcess("5552", "2b7e151628aed2a6abf7158809cf4f3c", 128, 1)
MsgBox(0, "Encrypted data", $DataToBeEncrypted)
$DataToBeDecrypted =_EncryptionProcess($DataToBeEncrypted, "2b7e151628aed2a6abf7158809cf4f3c" ,128, 0)
MsgBox(0, "Decrypted data", $DataToBeDecrypted)


Func _EncryptionProcess($InputText, $GVKey, $Key = 128, $EncryptionNumber = 1)
    ;$GVKey takes the encryption that you want to be processed and puts it in Var
    ;$GVKey is the size of the key that you want to use, the $Key is what it will default too
;~  ;$EncryptionNumber deicdes if you want to encrypt it or not
;~         If $Key <> 128 And $Key <> 192 And $Key <> 256 Then
;~                 SetError(1, 0, 0)
;~         ElseIf StringLen($InputText) <> 32 Then
;~                 SetError(2, 0, 0)
;~         ElseIf StringLen($GVKey) <> 32 And $Key = 128 Then
;~                 SetError(3, 0, 0)
;~         ElseIf StringLen($GVKey) <> 48 And $Key = 192 Then
;~                 SetError(3, 0, 0)
;~         ElseIf StringLen($GVKey) <> 64 And $Key = 256 Then
;~                 SetError(3, 0, 0)
;~         ElseIf $EncryptionNumber <> 1 And $EncryptionNumber <> 0 Then
;~                 SetError(4, 0, 0)
;~         EndIf

        Local $LVOutput[16]
        Local $LVInput[16]
        Local $InputHex[32]
        Local $SubRoundKeyStep[240]
        Local $LV2 = 1
        Local $CheckValue
        Local $NumberOfRounds
        Local $LGVKey

        $LGVKey = $Key / 32 ;32 hexadecimals from 128 bits input
        $NumberOfRounds = $LGVKey + 6
;converts the hexadecimal to Decimal
        For $Var1 = 0 To $LGVKey * 4 - 1
                $InputHex[$Var1] = Dec(StringMid($GVKey, $LV2, 2))
                $LV2 = $LV2+ 2
        Next

        $LV2 = 1
        For $Var1 = 0 To 15
                $LVInput[$Var1] = Dec(StringMid($InputText, $LV2, 2))
                $LV2 = $LV2 + 2
        Next

        $SubRoundKeyStep = __TheyKeyExpansionStep($InputHex, $NumberOfRounds, $LGVKey)

        If $EncryptionNumber = 1 Then ;Encrypt
                $LVOutput = __Algorithm($LVInput, $SubRoundKeyStep, $NumberOfRounds) ; in this part you are going through the Algorithm function
                ;line 259 or approximate
        ElseIf $EncryptionNumber = 0 Then ; decrypt
                $LVOutput = __DecryptionProcess($LVInput, $SubRoundKeyStep, $NumberOfRounds)
        EndIf

        For $Var1 = 0 To 15
                $CheckValue &= $LVOutput[$Var1]
        Next

        Return $CheckValue
;converts the hexadecimal to decimal
EndFunc


Func __ValueOfTheSubstitutionBox($SubstitutionBoxNumber)
        Local $SubsitutionBoxOutput[256] = [0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75, 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF, 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8, 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73, 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB, 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08, 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A, 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16]
        Return $SubsitutionBoxOutput[Dec(Hex($SubstitutionBoxNumber, 2))]; making sure it is in hex a decimal allowing the language to read it
        ;it takes the input then creating a local Var and using the array of the s-box

EndFunc   ;==>__ValueOfTheSubstitutionBox


Func __TheyKeyExpansionStep($InputHex, $NumberOfRounds, $LGVKey) ;theese Vars define are defining the major parts of the things. How many rounds and how big the key needs to be
        Local $Var1
        Local $LV6
        Local $SubRoundKeyStep[240]
        Local $LV3[4]
        Local $TheRconFunction[255] = [0x8D, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36, 0x6C, 0xD8, 0xAB, 0x4D, 0x9A, 0x2F, 0x5E, 0xBC, 0x63, 0xC6, 0x97, 0x35, 0x6A, 0xD4, 0xB3, 0x7D, 0xFA, 0xEF, 0xC5, 0x91, 0x39, 0x72, 0xE4, 0xD3, 0xBD, 0x61, 0xC2, 0x9F, 0x25, 0x4A, 0x94, 0x33, 0x66, 0xCC, 0x83, 0x1D, 0x3A, 0x74, 0xE8, 0xCB, 0x8D, 0x01, 0x02,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, 0xD3, 0xBD, 0x61, 0xC2, 0x9F, 0x25, 0x4A, 0x94, 0x33, 0x66, 0xCC, 0x83, 0x1D, 0x3A, 0x74, 0xE8, 0xCB]

        For $Var1 = 0 To $LGVKey - 1
                $SubRoundKeyStep[$Var1 * 4] = $InputHex[$Var1 * 4]
                $SubRoundKeyStep[$Var1 * 4 + 1] = $InputHex[$Var1 * 4 + 1]
                $SubRoundKeyStep[$Var1 * 4 + 2] = $InputHex[$Var1 * 4 + 2]
                $SubRoundKeyStep[$Var1 * 4 + 3] = $InputHex[$Var1 * 4 + 3]
        Next
        While $Var1 < (4 * ($NumberOfRounds + 1))
                For $LV2 = 0 To 3
                        $LV3[$LV2] = $SubRoundKeyStep[($Var1 - 1) * 4 + $LV2]
                Next
                If Mod($Var1, $LGVKey) = 0 Then
                        $LV6 = $LV3[0]
                        $LV3[0] = $LV3[1]
                        $LV3[1] = $LV3[2]
                        $LV3[2] = $LV3[3]
                        $LV3[3] = $LV6
                        $LV3[0] = __ValueOfTheSubstitutionBox($LV3[0])
                        $LV3[1] = __ValueOfTheSubstitutionBox($LV3[1])
                        $LV3[2] = __ValueOfTheSubstitutionBox($LV3[2])
                        $LV3[3] = __ValueOfTheSubstitutionBox($LV3[3])
                        $LV3[0] = BitXOR($LV3[0], $TheRconFunction[$Var1 / $LGVKey])
                ElseIf $LGVKey > 6 And Mod($Var1, $LGVKey) = 4 Then
                        $LV3[0] = __ValueOfTheSubstitutionBox($LV3[0])
                        $LV3[1] = __ValueOfTheSubstitutionBox($LV3[1])
                        $LV3[2] = __ValueOfTheSubstitutionBox($LV3[2])
                        $LV3[3] = __ValueOfTheSubstitutionBox($LV3[3])
                EndIf

                $SubRoundKeyStep[$Var1 * 4 + 0] = BitXOR($SubRoundKeyStep[($Var1 - $LGVKey) * 4 + 0], $LV3[0])
                $SubRoundKeyStep[$Var1 * 4 + 1] = BitXOR($SubRoundKeyStep[($Var1 - $LGVKey) * 4 + 1], $LV3[1])
                $SubRoundKeyStep[$Var1 * 4 + 2] = BitXOR($SubRoundKeyStep[($Var1 - $LGVKey) * 4 + 2], $LV3[2])
                $SubRoundKeyStep[$Var1 * 4 + 3] = BitXOR($SubRoundKeyStep[($Var1 - $LGVKey) * 4 + 3], $LV3[3])
                $Var1 = $Var1 + 1
        WEnd
        Return $SubRoundKeyStep
EndFunc   ;==>__TheyKeyExpansionStep
Func __TheAddRoundKeyStep($LV9, $SubRoundKeyStep, $CurrentState) ; The add round key step
        For $Var1 = 0 To 3
                For $LV2 = 0 To 3
                        $CurrentState[$LV2][$Var1] = BitXOR($CurrentState[$LV2][$Var1], $SubRoundKeyStep[$LV9 * 4 * 4 + $Var1 * 4 + $LV2])
                Next
        Next
; It takes the currect state value and BitXOR it with the the round key
; the multiplication and addition process figures out what number it is
; the $LV9 Step is needed
        Return $CurrentState
EndFunc   ;==>__TheAddRoundKeyStep
Func __SubBytes($CurrentState)
        For $Var1 = 0 To 3
                For $LV2 = 0 To 3
                        $CurrentState[$Var1][$LV2] = __ValueOfTheSubstitutionBox($CurrentState[$Var1][$LV2])
                Next
        Next

        Return $CurrentState
EndFunc   ;==>__SubBytes
Func __InvSubBytes($CurrentState)
        For $Var1 = 0 To 3 ;4loops
                For $LV2 = 0 To 3
                        $CurrentState[$Var1][$LV2] = __ValueOfTheInvertSubstitutionBox($CurrentState[$Var1][$LV2]); this is calling another function which is the get S-BOX value function
                        ;the long line is this function
                Next
        Next

        Return $CurrentState
EndFunc   ;



Func __TheShiftRowStep($CurrentState) ; this is the shift row step.
                            ; $CurrentState is the input
        Local $LV3
                            ;this is the temporary Var

        $LV3 = $CurrentState[1][0]
        $CurrentState[1][0] = $CurrentState[1][1] ; As you can see the [1][0] gets moved over to [1][1] hence shfting it
        $CurrentState[1][1] = $CurrentState[1][2]
        $CurrentState[1][2] = $CurrentState[1][3]
        $CurrentState[1][3] = $LV3
        $LV3 = $CurrentState[2][0]
        $CurrentState[2][0] = $CurrentState[2][2]; it does this the correct time
        $CurrentState[2][2] = $LV3
        $LV3 = $CurrentState[2][1]
        $CurrentState[2][1] = $CurrentState[2][3]
        $CurrentState[2][3] = $LV3
        $LV3 = $CurrentState[3][0]
        $CurrentState[3][0] = $CurrentState[3][3]
        $CurrentState[3][3] = $CurrentState[3][2]
        $CurrentState[3][2] = $CurrentState[3][1]
        $CurrentState[3][1] = $LV3

        Return $CurrentState
EndFunc   ;==>__TheShiftRowStep
Func __TheInverseShiftRowSetp($CurrentState)
        Local $LV3

        $LV3 = $CurrentState[1][3]
        $CurrentState[1][3] = $CurrentState[1][2]
        $CurrentState[1][2] = $CurrentState[1][1]
        $CurrentState[1][1] = $CurrentState[1][0]
        $CurrentState[1][0] = $LV3
        $LV3 = $CurrentState[2][0]
        $CurrentState[2][0] = $CurrentState[2][2]
        $CurrentState[2][2] = $LV3
        $LV3 = $CurrentState[2][1]
        $CurrentState[2][1] = $CurrentState[2][3]
        $CurrentState[2][3] = $LV3
        $LV3 = $CurrentState[3][0]
        $CurrentState[3][0] = $CurrentState[3][1]
        $CurrentState[3][1] = $CurrentState[3][2]
        $CurrentState[3][2] = $CurrentState[3][3]
        $CurrentState[3][3] = $LV3

        Return $CurrentState
EndFunc   ;==>__TheInverseShiftRowSetp
Func __factor($LVMultiplication)
        Return BitXOR(BitShift($LVMultiplication, -1), (BitAND(BitShift($LVMultiplication, 7), 1) * 0x1B)); this function is used in the Mix Column step
        ; the 0x1B is a hexadecimal number
EndFunc   ;==>__factor
Func __Multiplication($LVMultiplication, $LVMultiplication2)
        Return BitXOR((BitAND($LVMultiplication2, 1) * $LVMultiplication), (BitAND(BitShift($LVMultiplication2, 1), 1) * __factor($LVMultiplication)), (BitAND(BitShift($LVMultiplication2, 2), 1) * __factor(__factor($LVMultiplication))), (BitAND(BitShift($LVMultiplication2, 3), 1) * __factor(__factor(__factor($LVMultiplication)))), (BitAND(BitShift($LVMultiplication2, 4), 1) * __factor(__factor(__factor(__factor($LVMultiplication))))))
EndFunc   ;==>__Multiplication
Func __TheMixColumnStep($CurrentState); the input that is used
        Local $LV5p ; your temporrary Vars
        Local $LV5
        Local $LVMixColumnT

        For $Var1 = 0 To 3; You have your 4 loops here (4 columns)
                $LVMixColumnT = $CurrentState[0][$Var1]
                $LV5p = BitXOR($CurrentState[0][$Var1], $CurrentState[1][$Var1], $CurrentState[2][$Var1], $CurrentState[3][$Var1])
                $LV5 = BitXOR($CurrentState[0][$Var1], $CurrentState[1][$Var1])
                $LV5 = __factor($LV5) ; this is calling the _Factor function
                $CurrentState[0][$Var1] = BitXOR($CurrentState[0][$Var1], BitXOR($LV5, $LV5p))
                $LV5 = BitXOR($CurrentState[1][$Var1], $CurrentState[2][$Var1])
                $LV5 = __factor($LV5)
                $CurrentState[1][$Var1] = BitXOR($CurrentState[1][$Var1], BitXOR($LV5, $LV5p))
                $LV5 = BitXOR($CurrentState[2][$Var1], $CurrentState[3][$Var1])
                $LV5 = __factor($LV5)
                $CurrentState[2][$Var1] = BitXOR($CurrentState[2][$Var1], BitXOR($LV5, $LV5p))
                $LV5 = BitXOR($CurrentState[3][$Var1], $LVMixColumnT)
                $LV5 = __factor($LV5)
                $CurrentState[3][$Var1] = BitXOR($CurrentState[3][$Var1], BitXOR($LV5, $LV5p))
        Next

        Return $CurrentState
EndFunc   ;==>__TheMixColumnStep

Func __Algorithm($LVInput, $SubRoundKeyStep, $NumberOfRounds)
    ;$NumberOfRounds states the number of rounds
    ;$SubRoundKeyStep uses the round function
    ;$LVInput is the Var for the input

        Local $LVOutput[16]
        Local $CurrentState[4][4]

        For $Var1 = 0 To 3
                For $LV2 = 0 To 3
                        $CurrentState[$LV2][$Var1] = $LVInput[$Var1 * 4 + $LV2]
                        ;This part is the 2 dimensinal array; this part is the one dimensional array
                        ; this converts the input from a 1 dimensional array to a 2 dimenasional

                Next
        Next

        $CurrentState = __TheAddRoundKeyStep(0, $SubRoundKeyStep, $CurrentState)
;the add round key step
        For $LV9 = 1 To $NumberOfRounds - 1
                $CurrentState = __SubBytes($CurrentState); these things are calling upon the functions to undergo their process in order
                $CurrentState = __TheShiftRowStep($CurrentState)
                $CurrentState = __TheMixColumnStep($CurrentState)
                $CurrentState = __TheAddRoundKeyStep($LV9, $SubRoundKeyStep, $CurrentState)
        ; the 9 rounds of the Subbytes, shiftroyws, mix columns and add round key step
        Next

        $CurrentState = __SubBytes($CurrentState)
        $CurrentState = __TheShiftRowStep($CurrentState)
        $CurrentState = __TheAddRoundKeyStep($NumberOfRounds, $SubRoundKeyStep, $CurrentState)
; this is the final round which does not include the mix column step
        For $Var1 = 0 To 3
                For $LV2 = 0 To 3
                        $LVOutput[$Var1 * 4 + $LV2] = Hex($CurrentState[$LV2][$Var1], 2)
                Next
        Next

        Return $LVOutput
EndFunc
Func __DecryptionProcess($LVInput, $SubRoundKeyStep, $NumberOfRounds)

        Local $LVOutput[16]
        Local $CurrentState[4][4]

        For $Var1 = 0 To 3
                For $LV2 = 0 To 3
                        $CurrentState[$LV2][$Var1] = $LVInput[$Var1 * 4 + $LV2]
                Next
        Next

        $CurrentState = __TheAddRoundKeyStep($NumberOfRounds, $SubRoundKeyStep, $CurrentState)

        For $LV9 = $NumberOfRounds - 1 To 1 Step -1
                $CurrentState = __TheInverseShiftRowSetp($CurrentState)
                $CurrentState = __InvSubBytes($CurrentState)
                $CurrentState = __TheAddRoundKeyStep($LV9, $SubRoundKeyStep, $CurrentState)
                $CurrentState = __InvTheMixColumnStep($CurrentState)
        Next

        $CurrentState = __TheInverseShiftRowSetp($CurrentState)
        $CurrentState = __InvSubBytes($CurrentState)
        $CurrentState = __TheAddRoundKeyStep(0, $SubRoundKeyStep, $CurrentState)

        For $Var1 = 0 To 3
                For $LV2 = 0 To 3
                        $LVOutput[$Var1 * 4 + $LV2] = Hex($CurrentState[$LV2][$Var1], 2)
                Next
        Next

        Return $LVOutput
EndFunc
Func __InvTheMixColumnStep($CurrentState)
        Local $Var1
        Local $LVMixColumn1
        Local $LVMixColumn2
        Local $LVMixColumn3
        Local $LVMixColumn4

        For $Var1 = 0 To 3
                $LVMixColumn1 = $CurrentState[0][$Var1]
                $LVMixColumn2 = $CurrentState[1][$Var1]
                $LVMixColumn3 = $CurrentState[2][$Var1]
                $LVMixColumn4 = $CurrentState[3][$Var1]

                $CurrentState[0][$Var1] = BitXOR(__Multiplication($LVMixColumn1, 0x0e), __Multiplication($LVMixColumn2, 0x0b), __Multiplication($LVMixColumn3, 0x0d), __Multiplication($LVMixColumn4, 0x09))
                $CurrentState[1][$Var1] = BitXOR(__Multiplication($LVMixColumn1, 0x09), __Multiplication($LVMixColumn2, 0x0e), __Multiplication($LVMixColumn3, 0x0b), __Multiplication($LVMixColumn4, 0x0d))
                $CurrentState[2][$Var1] = BitXOR(__Multiplication($LVMixColumn1, 0x0d), __Multiplication($LVMixColumn2, 0x09), __Multiplication($LVMixColumn3, 0x0e), __Multiplication($LVMixColumn4, 0x0b))
                $CurrentState[3][$Var1] = BitXOR(__Multiplication($LVMixColumn1, 0x0b), __Multiplication($LVMixColumn2, 0x0d), __Multiplication($LVMixColumn3, 0x09), __Multiplication($LVMixColumn4, 0x0e))
        Next

        Return $CurrentState
EndFunc

Func __ValueOfTheInvertSubstitutionBox($SubstitutionBoxNumber)
        Local $LVSubsitutionBox[256] = [0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25, 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, 0x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C, 0x7D]
        Return $LVSubsitutionBox[Dec(Hex($SubstitutionBoxNumber, 2))]
EndFunc   ;==>__ValueOfTheInvertSubstitutionBox

;***** Hexadecimals to ASCII*****


$HexadecimalToASCII2 = "$DataToBeDecrypted"
$HexadecimalsToASCII = ChrH($HexadecimalToASCII2)
$Ascii2Hex = Sub($HexadecimalsToASCII)
$v5ar = Chr($HexadecimalsToASCII);char

MsgBox(0,"Hex to ASCII",$HexadecimalsToASCII)

Func ChrH($v8)

    Local $v5=""
    $A1 = StringSplit($v8, " ")
    For $count = 1 To $A1[0]
        $v5 &= Chr(Dec($A1[$count]))
    Next
    Return $v5
endFunc


Func Sub($v8)

    Local $v9=""
    For $count = 1 To StringLen($v8)
        If StringLen(Hex(Asc(StringMid($v8, $count, 1)),2)) = 1 Then
            $v9 &=  "0" & Hex(Asc(StringMid($v8, $count, 1)))
        Else
            $v9 &=  Hex(Asc(StringMid($v8, $count, 1)),2)
        EndIf
        If $count <> StringLen($v8) Then $v9 &=  " "
    Next
    Return $v9
endFunc

 

Share this post


Link to post
Share on other sites
MikahS

@Melba23,

I am having an off day, as I remember Jon saying essentially that.

My apologies.

 

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
bahjat

@Melba23,

I am having an off day, as I remember Jon saying essentially that.

My apologies.

 

​I think i have used the code tag correctly, can you please help me?

Share this post


Link to post
Share on other sites
MikahS

Yes, you have done it correctly.

What functions in your script is the **ASCII to Hex*** function and the ****INPUT your text**** function?


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
bahjat

So you want us to go through several hundred lines of code, with nothing more to go on than "it's broke"? How about a little more information, such as the error you're getting when you try to run it. If it is simply hanging up, you can put the following at the top of the screen to help you figure out where it is failing:

Opt("TrayIconDebug", 1)

 

​The problem arises when the programs are put together

The input to text part takes the input from the user to store it in a variable. 

***ASCII to Hex*** takes the input and turns it into Hexadecimals so that the encryption can be processed. . 

Share this post


Link to post
Share on other sites
bahjat

Yes, you have done it correctly.

What functions in your script is the **ASCII to Hex*** function and the ****INPUT your text**** function?

MikahS,

Please stop suggesting people use the [ code ] tags - BB codes are not necessarily honoured by the new editor.  It is now recommended to use the editor "code" button.

M23

So you want us to go through several hundred lines of code, with nothing more to go on than "it's broke"? How about a little more information, such as the error you're getting when you try to run it. If it is simply hanging up, you can put the following at the top of the screen to help you figure out where it is failing:

Opt("TrayIconDebug", 1)

 

​if you guys are still interested in helping me, i have found the exact problem with my program. Their wasn't any problem with the ASII to Hex conversion or the input part of the problem. The problem is when you introduce the space button into the program, as said before if you input "5552" the program works perfect but if you input "55 52" the program doesn't seem to encrypt correctly. It for some reason can't seem to detect the space between the numbers

Share this post


Link to post
Share on other sites
BrewManNH

Why aren't you using the Crypt.au3 encryption functions to encrypt whatever it is you're encrypting? At least you'll know that they've been tested and work and are at least as secure as they can be, rather than trying to invent your own encryption functionality and having the encryption broken in 10 seconds.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
bahjat

Why aren't you using the Crypt.au3 encryption functions to encrypt whatever it is you're encrypting? At least you'll know that they've been tested and work and are at least as secure as they can be, rather than trying to invent your own encryption functionality and having the encryption broken in 10 seconds.

​i thought i was using the crypt.au3 function? I believe it is stated on line 3. 
And i am doing this for personal pleasure, i won't be sending my card details using this encryption technique. 

Share this post


Link to post
Share on other sites
BrewManNH

​i thought i was using the crypt.au3 function? I believe it is stated on line 3. And i am doing this for personal pleasure, i won't be sending my card details using this encryption technique. 

​You have it included in your script, but no where in your script are you actually using any of its functions. BTW, you have a $keyvalue variable in your TextInput function that isn't used anywhere else in your script. I don't know what that value is supposed to be used for, but you're not using it anywhere.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
bahjat

​You have it included in your script, but no where in your script are you actually using any of its functions. BTW, you have a $keyvalue variable in your TextInput function that isn't used anywhere else in your script. I don't know what that value is supposed to be used for, but you're not using it anywhere.

​I have figured out the problem. When the input from the user is converted into hexadecimals it goes something like this "32 32 02 05 54" the AES program doesn't recognise the space between each digit and hence cannot function properly. I need a program that deletes this space so it becomes "3232020554". That way it will be able to read the input data. It's kind of bad, can you guide me how to do this please?

Share this post


Link to post
Share on other sites
jchd

You really don't seem to read replies!

Please have a look here again.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
BrewManNH

​I have figured out the problem. When the input from the user is converted into hexadecimals it goes something like this "32 32 02 05 54" the AES program doesn't recognise the space between each digit and hence cannot function properly. I need a program that deletes this space so it becomes "3232020554". That way it will be able to read the input data. It's kind of bad, can you guide me how to do this please?

​Why are you converting the text into a hexadecimal number anyways? Just take your text , feed it to one of the encryption functions in Crypt.au3 and be done. BTW, if you want to strip whitespace from a string you might want to look in the help file and look at the string functions listed in it.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
bahjat

​Why are you converting the text into a hexadecimal number anyways? Just take your text , feed it to one of the encryption functions in Crypt.au3 and be done. BTW, if you want to strip whitespace from a string you might want to look in the help file and look at the string functions listed in it.

​can i get more information on these crypt functions please

Share this post


Link to post
Share on other sites
BrewManNH

​can i get more information on these crypt functions please

​Yes you can, read the help file.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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

  • Similar Content

    • ufukreis1212
      By ufukreis1212
      Hello, I am new members. Help me please. I want vbs convert to au3 .
      This vbs code : 
      'deneme Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem") strOSArch = GetObject("winmgmts:root\cimv2:Win32_OperatingSystem=@").OSArchitecture Set objNetwork = CreateObject("Wscript.Network") Set wshShell = CreateObject( "WScript.Shell" ) strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) Set oShell = WScript.CreateObject("WScript.Shell") proc_arch = oShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%") Set oEnv = oShell.Environment("SYSTEM") strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colMB = objWMIService.ExecQuery("Select * from Win32_BaseBoard") Set colCSes = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor") Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItemsx = objWMIService.ExecQuery( _ "SELECT * FROM Win32_VideoController",,48) '------------------------------------------------------------------- Set obj = GetObject("winmgmts:").InstancesOf("Win32_PhysicalMemory") i = 1 For Each obj2 In obj memTmp1 = obj2.capacity / 1024 / 1024 TotalRam = TotalRam + memTmp1 i = i +1 Next '-------------------------------------------------------------------- Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select Architecture from Win32_Processor") For Each objItem in colItems if objItem.Architecture = 0 then strArchitecture = "x86" end if if objItem.Architecture = 9 then strArchitecture = "x64" end if next '-------------------------------------------------------------------- strComputer = "." ' Local computer strMemory = "" i = 1 set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory") For Each objItem In colItems if strMemory <> "" then strMemory = strMemory & vbcrlf strMemory = strMemory & "Bank" & i & " : " & (objItem.Capacity /1024 /1024) & " Mb" i = i + 1 Next installedModules = i - 1 Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemoryArray") For Each objItem in colItems totalSlots = objItem.MemoryDevices Next '---------------------------------------------------------------------- Set objWMISvc = GetObject( "winmgmts:\\.\root\cimv2" ) Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem" ) For Each objItem in colItems strComputerDomain = objItem.Domain Next for each System in SystemSet For Each objItem in colItemsx For Each objProcessor in colProcessors For Each bbType In colMB MbVendor = bbType.Manufacturer MbModel = bbType.Product MsgBox "İşletim Sistemi : " & System.Caption & vbNewLine & _ "İşletim Sistemi Versionu : " & + System.Version & vbNewLine & _ "Windows Mimari Yapısı: " & strOSArch & vbNewLine & _ "Kullanıcı isminiz: " & objNetwork.UserName & vbNewLine & _ "Bilgisayar ismi: " & strComputerName & vbNewLine & _ "Çalışma Grubu: " & strComputerDomain & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Anakart: " & MbVendor & " " & "[" & MbModel & "]" & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Grafik Kartı: " & objItem.Caption & vbNewLine & _ "Driver Version: " & objItem.DriverVersion & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "İşlemci Üreticisi: " & objProcessor.Manufacturer & vbNewLine & _ "İşlemci İsmi: " & objProcessor.Name & vbNewLine & _ "CPU Mimarisi: " & strArchitecture & vbNewLine & _ "İşlemci Çekirdek sayısı: " & oEnv("NUMBER_OF_PROCESSORS") & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Toplam RAM: " & TotalRam & " MB" & vbNewLine & _ "Toplam Slot: " & totalSlots & vbNewLine & _ "Boş Slot: " & (totalSlots - installedModules) & vbNewLine & _ "Ramlerin bulunduğu slotlar:" & vbcrlf & strMemory,0,"deneme" Next Next Next Next please help me , thanks.
    • JuanFelipe
      By JuanFelipe
       
      Hello friends, I have a query, it happens that I have a matrix nxn, the first column of this contains each cell a number with 21 digits, when I pass this matrix to Excel I obviously write that number as 1,10016E + 20, I solved it by adding a * at the end of each cell, but I want it to be written as a text so that I do not have to remove that *, I searched in Google but could not find an effective solution, thanks in advance. 
    • Puls3
      By Puls3
      Hi, This is my first post on the AutoIt Forums, I most of the time was able to get help from this community by merely searching though google and have been able to solve hundreds of problems this way, though in this case I was incapable of finding a solution to my problem. I am quite confident that it is a user error (And my fault) but I haven't been able to determine what I did wrong, any and all help would be greatly appreciated! I have uploaded my whole script pardon passwords to provide as much information as possible.
      I declared a global array at the top of the script and am having issues when I try to set it's value, and I fail to understand why.
      Error Message:
      "D:\Projects\AutoIt\Arena\Base.au3" (270) : ==> Subscript used on non-accessible variable.:
      $ExpMax[$i] = IniRead($TempSavePath, "Combatant" & $i, "ExpMax", $ExpMax[0])
      $ExpMax^ ERROR
      ConsoleWrite Log:
      Ran.
      Checking launch parameters.
      No launch parameters.
      Initiating load.
      Checking for save file.
      Save file not found.
      Load canceled.
      Loading or creating Combatant 1
      Base.au3
    • RamDemon
      By RamDemon
      Hi,
      Did anyone tried to  use Redis  with AutoIT as store DB ?
       Redis <-- more about it
      Mladen
    • nooneclose
      By nooneclose
      Hey. I'm working on a new project and was wondering if there is a better way to "update" my Column E array. 
      Here is my code: 
      Local $nI  = 0                                                            ;Creates a name index of 0: nI = Name index Local $nII = 1                                                            ;Creates a name index of 1 for second loop: nII = Name Index 2 For    $iN = 0 To $IndexRows Step 1                                       ;Checks the roster for any names that appear twice      For $iN2 = 0 To $IndexRows Step 1          if $d_Names[$nI] == $d_Names[$nII] And $d_Names[$nII] <> "" Then              Local $timeSheetName = _ArraySearch($e_Names, $d_Names[$nI], 0, 0, 0, 0, 1)              ;MsgBox($MB_SYSTEMMODAL, "Found it", $d_Names[$nI] & " In column E on Row " & $timeSheetName)              Local $eI  = $timeSheetName + 1              ;ConsoleWrite($timeSheetName & @CRLF)              ;ConsoleWrite($eI & @CRLF)              ;ConsoleWrite(@CRLF)              _Excel_RangeInsert($OpenWorkbook.ActiveSheet, "E" & $eI & ":F" & $eI, $xlShiftDown)                                                                          ;Inserts a empty cell in columns E and F.              _Excel_RangeWrite($OpenWorkbook, $OpenWorkbook.ActiveSheet, $d_Names[$nII], "E" & $eI)                                                                         ;Fills the empty cell in columns E with the doubled name              $aArray_Index = 2                                           ;Array element counter              For $Index = 2 To $IndexRows Step 1                        ;Loops through every row in the Excel file unto no rows are found or a null row is found                  $Array_Value_E = _Excel_RangeRead($OpenWorkbook, Default, "E"&$Index)                  $e_names[$aArray_Index] = $Array_Value_E                ;While the code loops every value in column E is stored in the E array (updating the array)                  $aArray_Index += 1              Next              ExitLoop          EndIf      Next      $nI  += 1      $nII += 1 Next Basically, It checks a roster for people whose name appears twice then inserts a new "row" for that person because they work in two different departments.
      I have to find that name however in Column E if two appear in column D. My code works but I think it is not as efficient as it could be. 
      Any ideas on how to improve the "update" for my array?
      (once it finds the double names in Column D it then searches for that name by going name by name in the Column E array and once it finds it inserts a new row. However, the E array doesn't have that new row stored in it so I have to "update" the array to properly find the next name)
      Any and all tips would be greatly appreciated. 
       
      NOTE: Just assume I'm opening the excel file properly please do not add that code in, it only complicates your answer. 
×