Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Python Assignment 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import binascii
from hextobase64 import convertHex

# predefined strings for testing the function
str1 = b"1c0111001f010100061a024b53535009181c"
str2 = b"686974207468652062756c6c277320657965"

# function to XOR two strings
def xorStr(user1, user2):
if(len(user1)==len(user2)):
# Make an iterator that aggregates elements from each of the raw strings.
zipp = zip(convertHex(user1),convertHex(user2))
# XOR of elements
theList = ((chr((a^b)) for a,b in zipp))
# making of the string
theString = ("".join(theList))
# turning string to bytes
finalBytes = theString.encode()
# turning bytes to hex
finalHex = binascii.b2a_hex(finalBytes)
#skadooooooosh
print (finalHex)

else:
print("Enter two strings with same length")

if __name__ == "__main__":
xorStr(str1, str2)