First, what is the algorithm module: module hash algorithm module i.e., a class hash algorithm, the received content is through some kind of operation to obtain the hash value of a string process.
Two, hash worth Features
1, not the value of the contents of the original anti solved by hash.
2, the same content obtained through the same hash algorithm must be the same hash value.
3, no matter how much the size of the incoming content, the length of the hash value derived through the same hash algorithm are the same.
Third, the use of hash algorithm
1, and may be transmitted to verify the password encrypted according to their characteristics can not be inverse solution.
2, according to its length corresponding to the characteristics and the like may be used to verify the integrity of the files.
Fourth, the specific use
import hashlib dongles = hashlib.md5 ( ' AAA ' .encode ( ' UTF-. 8 ' )) # obtained hash operation and declare stack md5 algorithm, and the first portion of the incoming content 'AAA' dongles.update ( ' BBB ' .encode ( ' . 8-UTF ' )) # pass the second part of dongles.update ( ' CCC ' .encode ( ' UTF-. 8 ' )) # incoming content third portion Print (dongles.hexdigest ()) # heap together into the content hash value, the result is d1aaf4767a3c10a473407a4e47b02da6