可以用来教少年们进行个加密解密启蒙的小程序。
"""加密程序"""
plain_text = "This is a test. ABC abc"
encrypted_text = "" # 加密后的文本
for c in plain_text:
x = ord(c) # 求它的ASCII码
x = x + 1
c2 = chr(x) # 取ASCII码对应的字符
encrypted_text = encrypted_text + c2
print(encrypted_text)
"""解密程序"""
encrypted_text = "Uijt!jt!b!uftu/!BCD!bcd"
plain_text = ""
for c in encrypted_text:
x = ord(c)
x = x - 1
c2 = chr(x)
plain_text = plain_text + c2
print(plain_text)
