Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Code Laura Barber
- #3/3/14
- #Crypto I
- #Problem 2(b)
- from binascii import unhexlify, hexlify
- c1= "4ADD55BA941FE954"
- c2= "5AC643BE8504E35E"
- def xor(input1,input2):
- result = int(input1, 16) ^ int(input2,16) #int conversion and xor
- return '{:x}'.format(result) #back to hex
- def main():
- xoredCipher=xor(c1,c2)
- print(xoredCipher)
- with open('english.0','r') as f:
- for line in f.readlines():
- binary = ''.join(format(ord(x), 'b') for x in line[:-1]) #conversion to binary
- bstr = binary.replace(' ','') #removing spaces
- hexstr = hex(int(bstr,2)) #binary to hex
- z=xor(xoredCipher,hexstr)
- if z==hexstr: #checking against wordlist again
- print("found")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement