Challenge

Write a function that takes two equal-length buffers and produces their XOR combination.


Script

def xor(a,b): if len(a) != len(b): return -1 c = '' for i in range(len(a)): c += chr(ord(a[i]) ^ ord(b[i])) return c if __name__ == '__main__': s1 = '1c0111001f010100061a024b53535009181c'.decode('hex') s2 = '686974207468652062756c6c277320657965'.decode('hex') result = xor(s1, s2) print result.encode('hex')


Result




'The Cryptopals Crypto Challenges' 카테고리의 다른 글

Single-byte XOR cipher  (9) 2018.10.14
01 Convert hex to base64  (0) 2018.10.13
Lets' start the crypto study!  (1) 2018.10.12

+ Recent posts