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条)