Skip to content

Commit

Permalink
V0.2.3 Works with online AES tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent-G-Van committed Jul 22, 2017
1 parent 17ed36a commit 16d08e4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
9 changes: 8 additions & 1 deletion AESdecrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
PassPhrase=input()#takes in user input of char, eg. "Iwanttolearnkung"
if(len(PassPhrase)<16):#check if less than 16 characters, if so add one space character until 16 chars
while(len(PassPhrase)!=16):
PassPhrase=PassPhrase+" "
PassPhrase=PassPhrase+"\00"
if(len(PassPhrase)>16):#check if bigger than 16 characters, if so then truncate it to be only 16 chars from [0:16]
print("Your passphrase was larger than 16, truncating passphrase.")
PassPhrase=PassPhrase[0:16]
Expand Down Expand Up @@ -90,6 +90,13 @@
start = start + 32 #increment start pointer
end = end + 32 #increment end pointer

replacementptr = 0
while (replacementptr < len(myhexstring)):
if (myhexstring[replacementptr:replacementptr + 2] == '0d'):
myhexstring = myhexstring[0:replacementptr] + myhexstring[replacementptr+2:len(myhexstring)]
else:
replacementptr = replacementptr + 2

outputhex = BitVector(hexstring=myhexstring)
asciioutput = outputhex.get_bitvector_in_ascii()
asciioutput=asciioutput.replace('\x00','')
Expand Down
23 changes: 18 additions & 5 deletions AESencrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
PassPhrase=input()#takes in user input of char, eg. "Iwanttolearnkung"
if(len(PassPhrase)<16):#check if less than 16 characters, if so add one space character until 16 chars
while(len(PassPhrase)!=16):
PassPhrase=PassPhrase+" "
PassPhrase=PassPhrase+"\00"
if(len(PassPhrase)>16):#check if bigger than 16 characters, if so then truncate it to be only 16 chars from [0:16]
print("Your passphrase was larger than 16, truncating passphrase.")
PassPhrase=PassPhrase[0:16]
Expand All @@ -23,6 +23,18 @@
print("Inside your plaintext message is:\n%s\n" % message)
file.close()

message=BitVector(textstring=message)
message=message.get_bitvector_in_hex()
replacementptr=0
while(replacementptr<len(message)):
if(message[replacementptr:replacementptr+2]=='0a'):
message=message[0:replacementptr]+'0d'+message[replacementptr:len(message)]
replacementptr=replacementptr+4
else:
replacementptr=replacementptr+2

message=BitVector(hexstring=message)
message=message.get_bitvector_in_ascii()
#set up some parameters
start=0#set starting pointer for the part to encrypt of the plaintext
end=0#set ending pointer for the part to encrypt of the plaintex
Expand Down Expand Up @@ -54,10 +66,11 @@
plaintextseg = message[start:end + 16]
else: #or else if the end pointer is equal to or greator than the size of the message
plaintextseg = message[start:length]
for z in range(0,((end+16)-length),2): #run a while loop to pad the message segement to become 16 characters, if it is 16 already the loop will not run
plaintextseg=BitVector(textstring=plaintextseg)
plaintextseg=plaintextseg.get_bitvector_in_hex()+"00"
plaintextseg=BitVector(hexstring=plaintextseg).get_bitvector_in_ascii()
for z in range(0,((end+16)-length),1): #run a while loop to pad the message segement to become 16 characters, if it is 16 already the loop will not run
plaintextseg = plaintextseg+"\00"
#plaintextseg2=BitVector(textstring=plaintextseg)
#print(plaintextseg2.get_bitvector_in_hex())

#add round key zero/ find round key one
bv1 = BitVector(textstring=plaintextseg)
bv2 = PassPhrase
Expand Down
2 changes: 1 addition & 1 deletion ciphertext.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23b8957075eb108938489dab52a23d28e10371bbe53b3f197ebb4e1f2a5156ea069785af12c48945afd8a78ea3705989
b84adf15adb05cbbcbaca78cff272ab0a02b211e2bd916d4a40c7b2d1dd57234
6 changes: 3 additions & 3 deletions plaintext1.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test3
setting up for demo
hi github
Two One Nine Two
Test4
Test5
6 changes: 3 additions & 3 deletions plaintext2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test3
setting up for demo
hi github
Two One Nine Two
Test4
Test5

0 comments on commit 16d08e4

Please sign in to comment.