def alphabetEncrypt(): inp = input("Enter a message: ") key = input("Enter key: ") output = "" for i in range(len(inp)): output = output + chr((ord(inp[i])+ord(key[i])-194)%26 + 97) print(output) def alphabetDecrypt(): inp = input("Enter a ciphertext: ") key = input("Enter the key: ") output = "" for i in range(len(inp)): working = ord(inp[i])-ord(key[i]) if working < 0: working += 26 else: working %= 26 working += 97 output = output + chr(working) print(output) def xorEncryptDecrypt(inp): key = input("Enter a key: ") inpb = "" for char in inp: inpb = inpb + format(ord(char), "08b") keyb = "" for char in key: keyb = keyb + format(ord(char), "08b") xor = int(inpb, 2) ^ int(keyb, 2) result = bin(xor)[2:].zfill(len(inpb)) chunks = [] for i in range(0, len(result), 8): chunks.append(result[i:i+8]) print(chunks) output = "" for chunk in chunks: output = output + (chr(int(chunk,2))) return output alphabetEncrypt() alphabetDecrypt() output = xorEncryptDecrypt("Hello") print(output) print("\n\n",xorEncryptDecrypt(output))