cryptopals

https://cryptopals.com/
Log | Files | Refs

repeating_key_xor.py (305B)


      1 def encrypt(key, msg):
      2     return ''.join([chr(ord(key[i % len(key)]) ^ ord(char)) for i, char in enumerate(msg)])
      3 
      4 plaintext = "Burning 'em, if you ain't quick and nimble"
      5 plaintext2 = "I go crazy when I hear a cymbal"
      6 key = "ICE"
      7 
      8 print encrypt(key, plaintext + "n" + plaintext2).encode("hex")