Cipher / app /cipher /caesar /decrypt.py
saptarshiroy39's picture
Modularized Codebase
dad4bb6
raw
history blame contribute delete
352 Bytes
def caesar_decrypt(ciphertext: str, key: int) -> dict:
plaintext = "".join(
chr((ord(c) - 65 - key) % 26 + 65) if c.isascii() and c.isupper()
else chr((ord(c) - 97 - key) % 26 + 97) if c.isascii() and c.islower()
else c
for c in ciphertext
)
return {
"key": key,
"plaintext": plaintext
}