900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > python编写凯撒密码的加密函数_python实现 古典密码 凯撒密码的加密与解密

python编写凯撒密码的加密函数_python实现 古典密码 凯撒密码的加密与解密

时间:2023-08-13 11:32:19

相关推荐

python编写凯撒密码的加密函数_python实现 古典密码 凯撒密码的加密与解密

python实现 古典密码 凯撒密码的加密与解密

实现效果如下图:

# 凯撒密码加密与解密

# author Sundm

string = [a,,c,d,e,f,g,h,i,j,k,l,m, ,o,p,q, ,s, ,u,v,w,x,y,z]

# 密文列表

cipher_text_list = []

# 明文列表

plain_text_list = []

# 凯撒密码加密函数

def encrypt():

cipher = int(input("请输入你的密钥:"))

plaintext = input("请输入你的明文:")

length = len(plaintext)

print("加密后的密文是:")

for i in range(0,length):

cipher_text_list.append(string[string.index(plaintext[i])+cipher])

print(cipher_text_list[i],end=&#

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。