Skip to content

Commit

Permalink
V0.1.3 work on decrypt p2
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent-G-Van committed Jul 13, 2017
1 parent 2e979be commit 5528353
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions AESdecrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@
roundkey9=findroundkey(roundkey8,9)
roundkey10=findroundkey(roundkey9,10)
roundkeys=[roundkey1,roundkey2,roundkey3,roundkey4,roundkey5,roundkey6,roundkey7,roundkey8,roundkey9,roundkey10]
print(roundkeys[9])
print("Roundkey 10 is: %s" % roundkeys[9])
# set up the segement message loop parameters
for y in range(1, loopmsg): # loop to encrypt all segments of the message
plaintextseg = message[start:end]
print(plaintextseg)
print("The ciphertext segment to decrypt is: %s" % plaintextseg)
# add round key
bv1 = BitVector(hexstring=plaintextseg)
bv2 = BitVector(hexstring=roundkeys[9])
resultbv = bv1 ^ bv2
myhexstring = resultbv.get_bitvector_in_hex()
print("The output after adding the roundkey 10 is: %s" % myhexstring)
#inverse shift row
myhexstring=invshiftrow(myhexstring)
print("The output after invshiftrow 10 is: %s" % myhexstring)
11 changes: 6 additions & 5 deletions AESdecryptfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def shiftrow(temp2):
return temp3

# shiftrow takes in a hex string of the size 8 or 32, then performs a shifting operation to output the a converted hex string
def shiftrow(temp2):
def invshiftrow(temp2):

if (len(temp2) == 8):
temp3 = temp2[6] + temp2[7] + temp2[0] + temp2[1] + temp2[2] + temp2[3] + temp2[4] + temp2[5]#in progress
Expand All @@ -169,12 +169,13 @@ def shiftrow(temp2):
# +temp2[18]+temp2[19]+temp2[28] + temp2[29] + temp2[6] + temp2[7] + temp2[16] + temp2[17] + temp2[26] + temp2[27]\
# + temp2[4] + temp2[5] + temp2[14] + temp2[15] + temp2[24] + temp2[25] + temp2[2] + temp2[3] + temp2[12] + temp2[13]\
# + temp2[22] + temp2[23]

# 00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
# 00,01,10,11,20,21,30,31,08,09,18,19,28,29,06,07,16,17,26,27,04,05,14,15,24,25,02,03,12,13,22,23
# working on this, second line
temp3=temp2[0]+temp2[1]+temp2[26]+temp2[27]+temp2[20]+temp2[21]+temp2[14]+temp2[15]+temp2[8]+temp2[9]\
+temp2[18]+temp2[19]+temp2[28] + temp2[29] + temp2[6] + temp2[7] + temp2[16] + temp2[17] + temp2[26] + temp2[27]\
+ temp2[4] + temp2[5] + temp2[14] + temp2[15] + temp2[24] + temp2[25] + temp2[2] + temp2[3] + temp2[12] + temp2[13]\
+ temp2[22] + temp2[23]
+temp2[2]+temp2[3]+temp2[28] + temp2[29] + temp2[22] + temp2[23] + temp2[16] + temp2[17] + temp2[10] + temp2[11]\
+ temp2[4] + temp2[5] + temp2[30] + temp2[31] + temp2[24] + temp2[25] + temp2[18] + temp2[19] + temp2[12] + temp2[13]\
+ temp2[6] + temp2[7]

return temp3

Expand Down

0 comments on commit 5528353

Please sign in to comment.