__author__ = 'Administrator'
#coding=utf-8
import hashlib
import base64
def strxor(a, b): # xor two strings of different lengths
if len(a) > len(b):
return "".join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a[:len(b)], b)])
else:
return "".join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a, b[:len(a)])])
print('密码高强度加密方法')
key='android123456'
salt='python'
print(key)
'''
data=strxor("123456",key)
print(data)
data=strxor("123456",data)
print(data)
'''
key1=base64.b64encode(key)
print(key1)
key2=hashlib.md5(key1+salt).hexdigest();
print(key2)
key3=hashlib.sha1(key2+salt).hexdigest();
print('该sha1密文不可逆')
print(key3)
key4=hashlib.sha512(key3+salt).hexdigest();
print('该sha512密文不可逆')
print(key4)
print('test===========')
print(hashlib.algorithms)
h=hashlib.new('md5')
print(h)
h.update('begin')
print(h.hexdigest())
print(h.digest())
print(h.digest_size)
print(h.block_size)
h2=hashlib.new('ripemd160','what')
print(h2)
print(h2.hexdigest())
print(h2.digest_size)
print(h2.block_size)