Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def encrypt_xor(plain_text, key):
- result = ''
- # iterate each char of word
- for i in range(len(plain_text)):
- # key to xor on
- xor = ord(key[i % len(key)])
- # char to xor
- char = ord(plain_text[i])
- # xor resutl
- res = char ^ xor
- # convert to hex
- res_hex = "{0:0{1}x}".format(res, 2)
- # append result
- result += res_hex
- return result
- if __name__ == "__main__":
- # input key
- key = input()
- # input plain text
- plain_text = input()
- # encryption
- cipher = encrypt_xor(plain_text, key)
- # result
- print(cipher)
Add Comment
Please, Sign In to add comment