def CaesarCipher(plaintext: str) -> str:
"""此为凯撒加密函数"""
res = ''
for s in plaintext:
if s.islower():
res += chr(((ord(s)-94)%26)+97)
elif s.isupper():
res += chr(((ord(s)-62)%26)+65)
else:
res = res+s
return res
def Decrypt(password: str) -> str:
"""此为解密函数"""
res = ''
for s in password:
if s.islower():
res += chr(((ord(s)-100)%26)+97)
elif s.isupper():
res += chr(((ord(s)-68)%26)+65)
else:
res = res+s
return res
plaintext = "I Love FishC.com"
password = "L Oryh IlvkF.frp"
print(CaesarCipher(plaintext))
print(Decrypt(password))
L Oryh IlvkF.frp
I Love FishC.com
|