Advertisement
Guest User

onetimedecrypt

a guest
Mar 3rd, 2014
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. #Code Laura Barber
  2. #3/3/14
  3. #Crypto I
  4. #Problem 2(b)
  5.  
  6. from binascii import unhexlify, hexlify
  7.  
  8. c1= "4ADD55BA941FE954"
  9. c2= "5AC643BE8504E35E"
  10.  
  11. def xor(input1,input2):
  12.     result = int(input1, 16) ^ int(input2,16) #int conversion and xor
  13.     return '{:x}'.format(result) #back to hex
  14.  
  15.  
  16. def main():
  17.     xoredCipher=xor(c1,c2)
  18.     print(xoredCipher)
  19.      
  20.     with open('english.0','r') as f:
  21.         for line in f.readlines():
  22.             binary = ''.join(format(ord(x), 'b') for x in line[:-1]) #conversion to binary
  23.             bstr = binary.replace(' ','') #removing spaces
  24.             hexstr = hex(int(bstr,2)) #binary to hex
  25.             z=xor(xoredCipher,hexstr)
  26.             if z==hexstr:   #checking against wordlist again
  27.                     print("found")
  28.  
  29. if __name__ == "__main__":
  30.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement