Liao is very vague in the article, I only know that the HMAC is generated by Password+key, which is similar to the method of adding salt in the previous section.
The following links are clearly explained by bloggers.
52175431
The HMAC algorithm is primarily used for authentication, using the following: 1. The client issues a logon request 2. The server returns a random value that is stored in the session record 3. The client sends the random value as the key, the user password for the HMAC, and submits it to the server 4. The server reads the database User password, use the key to do the same as the client's HMAC operation, and then compare with the results sent by the user, if consistent, the user identity is legitimate.
The salt is fixed, the user name is fixed, and is known to crack. However, HMAC is a key that is random every time, which is safer and more reliable than the salt method.
import hmacmessage = b ' hello, world! ' Key = b ' secret ' h = hmac.new (key, message, digestmod= ' MD5 ') # if the message is long, H.update (msg) print (H.hexdigest ()) can be called multiple times
Operation Result:
Fa4ee7d173f2d97ee79022d1a7355bcf
Python Summary: HMAC