有的内容并不怕别人看,但仍想简单加解密一下,可以考虑以下代码:
def encrypt(text): encrypted_text = "" for char in text: unicode_value = ord(char) + 10 # 在原有的Unicode值上加上10 encrypted_text += chr(unicode_value) return encrypted_text def decrypt(encrypted_text): decrypted_text = "" for char in encrypted_text: unicode_value = ord(char) - 10 # 在原有的Unicode值上减去10 decrypted_text += chr(unicode_value) return decrypted_text # 测试加解密功能 original_text = "你好龥龯龹鿃鿍鿗" print("Original Text:", original_text) encrypted_text = encrypt(original_text) print("Encrypted Text:", encrypted_text) decrypted_text = decrypt(encrypted_text) print("Decrypted Text:", decrypted_text)
标签:decrypted,python,text,简单,加解密,char,unicode,encrypted From: https://www.cnblogs.com/pu369/p/18009505