def fairplay_cipher(text, key): cipher = "" key_length = len(key) for i, char in enumerate(text): if char.isalpha(): ascii_offset = 65 if char.isupper() else 97 key_char = key[i % key_length] key_offset = ord(key_char) - ascii_offset cipher += chr((ord(char) + key_offset) % 26 + ascii_offset) else: cipher += char return cipher # Example usage: text = input("Enter the plaintext: ") key = input("Enter the key: ") result = fairplay_cipher(text, key) print("Cipher:", result)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter