维吉尼亚密码加密和解密算法的实现

维吉尼亚密码加密和解密算法的实现


2024年1月23日发(作者:)

维吉尼亚密码加密和解密算法的实现import numpy as np#加密函数def Encrypt(P,key): P=list(P) P=map(ord,P) P=(P) P=P-ord('a') m=len(P)/len(key)

n=len(P)%len(key) K=key*m+key[0:n]

C=(P+K)%26 C=C+ord('A') C=map(chr,C) C=''.join(C) return C

#解密函数def Decrypt(C,key): C=list(C) C=map(ord,C) C=(C) C=C-ord('A') m=len(C)/len(key)

n=len(C)%len(key)

K=key*m+key[0:n]

P=(C-K)%26 P=P+ord('a') P=map(chr,P) P=''.join(P) return P

#主函数


发布者:admin,转转请注明出处:http://www.yc00.com/web/1706006433a1434909.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信