Python简易加密与解密程序

Python简易加密与解密程序

"""加密程序.py"""
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)

###############################################

"""解密程序.py"""
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)

 

李兴球

李兴球的博客是Python创意编程原创博客