Tag:his sha-1 nts not -- microsoft exce mic ade
#python3.4
hashlib module-a Common interface to many hash functions.
hash.digest ()-Return the Digest of the The data passed to the update () method is far. This was a bytes object of size digest_size which may contain bytes in the whole range from 0 to 255.
hash.hexdigest ()-Like Digest () Except the digest is returned as a string object of double length, containing only hexadecimal digits. This is used to exchange, the value safely in email, or other non-binary environments.
Note 1:python 3 because the default is Unicode so arg in Update (ARG) if it is a string, you need to start with B, such as B "Hello world!!".
NOTE 2: MD5 For example, and checksum for 128bit data, corresponding to 16Byte data. However, this 16Byte cannot be represented directly by ASCII (storage, communication, etc.).
Therefore, using hexdigest to divide 128bit into 32 4bit data, 4bit data with Hex (0~9,A~F) ASCII representation. This is good for a lot of communication protocols, but also the wind convenient for people to read and compare.
MD5--128bit,sha-1--160bit, SHA-256--256bit, SHA-512--512bit
Example:
>>>import Hashlib
>>>HASHLIB.MD5 (b "Hello"). Digest ()
B '][email protected]*\xbck*v\xb9q\x9d\x91\x10\x17\xc5\x92 '
>>>HASHLIB.MD5 (b "Hello"). Hexdigest ()
' 5d41402abc4b2a76b9719d911017c592 '
1. Split the hexdigest as follows:
5d 2a BC 4b 2a B9-9d c5 92
2, every 2 for hex conversion to hex (which is greater than 0x80 of the conversion, some of the 0x0~0x7f also need to transfer. Can get
B '] A @ * \XBC K * v \xb9 q \x9d \x91 \x10 \x17 \xc5 \x92. and digest (right up).
Python Hashlib Notes