bahjat Posted April 29, 2015 Posted April 29, 2015 (edited) 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 programexpandcollapse popup#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, 0xBD, 0x61, 0xC2, 0x9F, 0x25, 0x4A, 0x94, 0x33, 0x66, 0xCC, 0x83, 0x1D, 0x3A, 0x74, 0xE8, 0xCB, 0x8D, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x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, 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, 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92, 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84, 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06, 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73, 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E, 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4, 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F, 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 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 April 29, 2015 by Melba23 Added code tags
MikahS Posted April 29, 2015 Posted April 29, 2015 (edited) Instead of using a quote to fill with code, use the code tool.Example:Global Enum $test = "test" ; testP.S. You can edit your posts on the bottom of each post with the Edit button. Edited April 29, 2015 by MikahS M23 Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy 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 Â
Moderators JLogan3o13 Posted April 29, 2015 Moderators Posted April 29, 2015 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) "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Moderators Melba23 Posted April 29, 2015 Moderators Posted April 29, 2015 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Â
bahjat Posted April 29, 2015 Author Posted April 29, 2015 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. expandcollapse popup#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, 0x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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, 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, 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, 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, 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] 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, 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0xB0, 0xC8, 0xEB, 0xBB, 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Â
MikahS Posted April 29, 2015 Posted April 29, 2015 (edited) @Melba23,I am having an off day, as I remember Jon saying essentially that.My apologies. Edited April 29, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy 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 Â
bahjat Posted April 29, 2015 Author Posted April 29, 2015 @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?
MikahS Posted April 29, 2015 Posted April 29, 2015 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 ~ getENVvarsMy 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 Â
bahjat Posted April 29, 2015 Author Posted April 29, 2015 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 togetherThe 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. .Â
bahjat Posted April 29, 2015 Author Posted April 29, 2015 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
BrewManNH Posted April 30, 2015 Posted April 30, 2015 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 GudeHow 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
bahjat Posted April 30, 2015 Author Posted April 30, 2015 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.Â
BrewManNH Posted April 30, 2015 Posted April 30, 2015 ​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 GudeHow 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
bahjat Posted May 1, 2015 Author Posted May 1, 2015 ​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?
jchd Posted May 1, 2015 Posted May 1, 2015 (edited) You really don't seem to read replies!Please have a look here again. Edited May 1, 2015 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 hereRegExp tutorial: enough to get startedPCRE 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)
BrewManNH Posted May 1, 2015 Posted May 1, 2015 ​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 GudeHow 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
bahjat Posted May 2, 2015 Author Posted May 2, 2015 ​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
BrewManNH Posted May 4, 2015 Posted May 4, 2015 ​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 GudeHow 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now