It seems like what you want is a caesar cipher which is relatively simple to do in python.
def encrypt(text, key):
"""Encrypts text using a ceaser cypher"""
encrypted = ""
for char in text:
if char.isalpha():
encrypted += chr((ord(char) + key - 97) % 26 + 97)
else:
encrypted += char
return encrypted
The only really weird part about this code is the unicode character madness. If you don't know unicode/ascii is a way to map numbers in a computers memory to characters which computer memory is fundamentally just 1's and 0's. here's a chart for all the relevant character
发布评论
评论(1)
看来您想要的是一个凯撒密码,在Python中相对简单。
关于此代码的唯一真正奇怪的部分是Unicode角色疯狂。如果您不知道Unicode/ascii是一种将计算机内存中映射到计算机内存的字符的方式,那么计算机内存在根本上只是1和0。这是所有相关字符的图表
It seems like what you want is a caesar cipher which is relatively simple to do in python.
The only really weird part about this code is the unicode character madness. If you don't know unicode/ascii is a way to map numbers in a computers memory to characters which computer memory is fundamentally just 1's and 0's. here's a chart for all the relevant character