cipher / app /services /caesar /decrypt.py
github-actions[bot]
Deploy from GitHub Actions: 60e5dc005ad8ef99d736feb3a3e36f304d0e8409
3e46134
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
}