File size: 352 Bytes
dad4bb6
cada743
 
 
 
dad4bb6
cada743
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
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
    }