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

    • JuanFelipe
      By JuanFelipe
      Hello friends, I have a simple question, can I have a variable that is not reset, even if my program is closed?
      That is, I want to make a program that can only be opened once, have a variable $ ini = 0, when it is opened for the first and only time it becomes $ ini = 1, so that it can not use the program a second time, as if it was a test software.
      I do not want the variable to depend on a reading of an external file that is easily manipulated. Thank you.
    • nooneclose
      By nooneclose
      My program has to first search for names in Column D that do not match up with column C. I got that search to work using arrays. It was slow and I could not figure out how to delete them so I just manually put coded the names that do not belong. I found their cell location but I do not know how to store that location and delete it.
      This is what I have so far.
      Local $NameToDelete1[6]  = _Excel_RangeFind($OpenWorkbook, "Smith, Bill") _ArrayDisplay($NameToDelete1, "Excel UDF: _Excel_RangeFind Example 1", "", 0, "|", "Sheet|Name|Cell|Value|Formula|Comment") _Excel_RangeDelete($OpenWorkbook.ActiveSheet, $NameToDelete1[2], $xlShiftUp)  
      Please help, I wanted to have this program done yesterday but I did not see this problem until yesterday. 
    • TrashBoat
      By TrashBoat
      So Im trying to make a simple 2d game and make some sort of collision detection so why not to make a 2 dimensional array but i have no clue how  to write it in multiple lines
      Global $map[5,5] = [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0] something like this but it doesn't work
    • Zein
      By Zein
      #include "..\Include\Array.au3" #include "..\Include\File.au3" #include "..\Include\AutoItConstants.au3" Local $aRetArray Local $sFilePath = "n.csv" _FileReadToArray($sFilePath, $aRetArray, ",") ; _FileReadToArray($sFilePath, $aRetArray, $FRTA_COUNT, ",") _ArrayDisplay($aRetArray, "Original", Default, 8) The above code shows two versions of _FileReadToArray and both don't work as expected.
      The first one doesn't use the comma as a delimiter. (so I get a single column array)  I tried adding "Default" between $aRetArray and "," then it told me it had an incorrect number of parameters. 

      I looked again at the documentation:
       
      #include <File.au3> _FileReadToArray ( $sFilePath, ByRef $vReturn [, $iFlags = $FRTA_COUNT [, $sDelimiter = ""]] )
      And I with or without the flags params I should be getting a 2D array due to my file being a csv. 
      I then tried a regular flag, $FRTA_COUNT, and it tells me that I'm using a variable $FRTA_COUNT while it's not declared. Tried putting in 1 instead and it told me again, incorrect number of params. 

       
    • nooneclose
      By nooneclose
      I need to perform a subtotal in excel and I would like to automate this process using Autoit if possible like always any and all help will be greatly appreciated. 
      I can not find a good example but the two from Microsoft. Here is one of the two from msdn.microsoft.com/en-us/vba/excel-vba/articles/range-subtotal-method-excel
      I do not really understand how to translate this into AutoIt, but I gave it a try and here is what I have.
      $OpenRange      = "A1:E200" $xlSum          = -4157 $Added_Array[2] = [2, 3] $OpenRange.Subtotal("B1", $xlSum, $Added_Array, True, False, True) I just need to perform a subtotal on a range based on a header called department, and then perform a sum on the results.
×