python实现维尼吉亚密码
来源:互联网 发布:dnf哪里数据芯片多 编辑:程序博客网 时间:2024/06/02 05:11
一 代码
#key='relations'
#plaintext='tomorrowiwillhaveagood'
key='helloworld'
plaintext=input('请输入明文:')
ascii='abcdefghijklmnopqrstuvwxyz'
keylen=len(key)
ptlen=len(plaintext)
ciphertext =''
i =0
while i < ptlen:
j = i % keylen
k = ascii.index(key[j])
m = ascii.index(plaintext[i])
ciphertext += ascii[(m+k)%26]
i +=1
print(ciphertext)
#维吉尼亚加密算法 解密
key='helloworld'
ciphertext=input('请输入密文:')
ascii='abcdefghijklmnopqrstuvwxyz'
keylen=len(key)
ctlen=len(ciphertext)
plaintext =''
i =0
while i < ctlen:
j = i % keylen
k = ascii.index(key[j])
m = ascii.index(ciphertext[i])
if m < k:
m +=26
plaintext += ascii[m-k]
i +=1
print(plaintext)
二 运行结果
请输入明文:tomorrowiwillhaveagood
asxzfncntzppwsorsrrrvh
请输入密文:asxzfncntzppwsorsrrrvh
tomorrowiwillhaveagood
阅读全文
0 0
- python实现维尼吉亚密码
- Playfair密码 Python实现
- Vigenere密码 Python实现
- Python实现判断强密码
- Python--实现密码强度检测器
- 栅栏密码解码python实现
- python版实现凯撒密码
- python实现换位密码算法
- Python实现星号遮掩的密码输入
- Python实现Telnet自动连接检测密码
- 使用python实现简单的序列密码
- Python 实现简单的密码判断
- [python] 密码学:代换密码的实现
- [python] 密码学:仿射密码的实现
- [python] 密码学:维吉尼亚密码的实现
- [python] 密码学:置换密码的实现
- python实现自动化登陆不需要密码
- python使用telnet实现弱密码登录
- Python单引号、双引号、三个双引号的区别
- 100+ 值得收藏的 Web 开发资源
- python版实现凯撒密码
- 天海投资推出海航云集市 天海投资行情稳定
- UE4蓝图节点翻译---Is Child Actor
- python实现维尼吉亚密码
- Mysql5.7在CentOS7上实现主从复制
- python实现换位密码算法
- hibernate系列一:入门篇
- 小错误
- python暴力破解MD5
- 【问底】徐汉彬:Web系统大规模并发——电商秒杀与抢购
- 如何在IDEA terminal中快速打开项目所在文件夹
- 图片上传预览,并且限制图片大小