xor加密
代码
import hashlib
hash_md5 = hashlib.md5()
x=input("输入文字:")
print( "Text:",x)
data = x.encode('utf-8', errors='ignore')
hash_md5.update(data)
md5_str = hash_md5.hexdigest()
print("MD5:",md5_str)
from random import *
zd="".join([choice("0123456789ABCDEF") for i in range(32)])
print ( "key:", zd)
txt1=[]
t=''
u=''
for a in range(32):
i='0x'+md5_str[a]
j='0x'+zd[a]
p=bin(eval(i)).replace('0b','')
q=bin(eval(j)).replace('0b','')
for c in range(min(len(p),len(q))):
if (p[-c]==q[-c]) :
e='0'
elif(p[-c]!=q[-c]):
e='1'
t=e+t
t='0b'+t
d=t
t=''
s=hex(eval(d)).replace('0x','')
u=u+s
print("CipherText:",u)
代码运行结果