Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
10-liner: re.sub solution in Clear category for Caesar Cipher (decryptor) by Stensen
import re
replace = lambda s, pos, chr: s[:pos] + chr + s[pos+1:]
def to_decrypt(t, d):
for idx, char in enumerate(t:=re.sub(r'[^a-z ]', '', t)):
if char.isalpha():
i = ord(char) + d
if i > 122: i = i-26
if i < 97: i = i+26
t = replace(t, idx, chr(i))
return t
Oct. 9, 2020
Comments: