XORMD5加密

#coding=utf-8
#md5jiami
import hashlib
hash_md5=hashlib.md5()
a=input('message')
print('message:',a)
data=a.encode('utf-8',errors='ignore')
hash_md5.update(data)
md5_str=hash_md5.hexdigest()
print('md5:',md5_str)

#xincheng key
from random import *
key=''.join([choice('0123456789ABCDEF')for i in range(32)])
print('key:',key)

#xor jiami
t=''
i='0x'+md5_str
j='0x'+key
p=bin(eval(i)).replace('0x','')
q=bin(eval(j)).replace('0x','')
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
u=hex(eval(t)).replace('0b','')
print('Ciper:'+u.replace('0x',''))

 

上一篇:Python文本读取 按关键字查找文件内容,并保存为文件


下一篇:JDBC连接数据库