Uh, today to look at encryption and decryption, this article discusses the Base64 and Hashlib libraries:
Look at Hashlib, he is a one-way summary of the method of setting the length string:
The code of the masturbate:
In []: import Time,hashlibin [+]: t = Int (time.time ()) in []: tout[20]: 1495597851In []: MD = HASHLIB.MD5 (' test%s '% t) in [+]: Md.hexdigest () out[22]: ' 8ed81a627d94055cd34d3e7e1d2fed72 ' in [23°c]: MD = HASHLIB.MD5 (' test%s '%t) in [24]: Md.hexdigest () out[24]: ' 8ed81a627d94055cd34d3e7e1d2fed72 ' in [+]: MD = HASHLIB.MD5 (' test123%s '%t) in [26]: Md.hexdigest () out[26]: ' 554aac9fa6ba5a5821f6a80e840b6b36 ' in [+]: MD = HASHLIB.MD5 (' test123%s '%t) in [28]: Md.hexdigest () out[28]: ' 554aac9fa6ba5a5821f6a80e840b6b36 '
The same string MD5 encrypted 16 binary is consistent
Next look at Base64.
In []: import base64in [+]: Base64.b64encode (' 123456 ') out[30]: ' MTIzNDU2 ' in []: Base64.b64decode (' MTIzNDU2 ') out[ 31]: ' 123456 '
can be calculated in reverse
The combination of both, Hee Hee
This article is from the "next door Lao Zhang" blog, please be sure to keep this source http://xxuer.blog.51cto.com/11947593/1928912
Python Encryption and decryption algorithm