def casearDecrypt(ciphertext, source_char, destination_char):
offset = ord(destination_char) - ord(source_char)
chars = "abcdefghijklmnopqrstuvwxyz"
for char in ciphertext:
is_upper_flag = 0
if char.isupper():
char = char.lower()
is_upper_flag = 1
if char not in chars:
outputChar(is_upper_flag, char)
continue
tempchar_ascii = ord(char) + offset
tempchar =chr(tempchar_ascii)
if tempchar not in chars:
if offset < 0:
tempchar_ascii += len(chars)
else:
tempchar_ascii -= len(chars)
tempchar = chr(tempchar_ascii)
outputChar(is_upper_flag, tempchar)
def outputChar(is_upper_flag, char):
if is_upper_flag == 1:
print(char.upper(), end="")
else:
print(char, end="")
ciphertext = input("Please input ciphertext:\n")
d
凯撒密码解密脚本(python)
最新推荐文章于 2026-04-03 10:20:45 发布
本文介绍了一种改进的凯撒密码解密脚本,该脚本增加了枚举所有可能偏移量的功能,以适应不同解密场景。


1857

被折叠的 条评论
为什么被折叠?



