python加密程序_Python加密程序
生活随笔
收集整理的這篇文章主要介紹了
python加密程序_Python加密程序
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
展開全部
alp='abcdefghijklmnopqrstuvwxyz0123456789?'
def?num2alp(c):
a?=?alp[c]
return(a)
def?alp2num(d):
if?d?!=?'?':
return((ord(d)-97)%37)
else:
return?36
def?envVigenere(key,plaintext):
m?=?len(plaintext)
n?=?len(key)
etext?=?""
for?i?in?range(m):
p?=?plaintext[i]
k?=?key[i%n]
num1?=?alp2num(p)
num2?=?alp2num(k)
num3?=?(num1+num2)%37
f?=?num2alp(num3)
etext?=?etext?+?f
return(etext)
print(envVigenere('lemon','attack?at?dawn'))
試試這個,我發(fā)現(xiàn)你的問題有兩個:alp2num
函數(shù)有問題,應(yīng)該再進行62616964757a686964616fe4b893e5b19e31333337613235下mod37,并且應(yīng)當對空格做特殊處理
key沒有使用正確使用
總結(jié)
以上是生活随笔為你收集整理的python加密程序_Python加密程序的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 西门子Step7和TIA软件“交叉引用”
- 下一篇: python中的成员运算符_在Pytho