Python Summary: HMAC

Source: Internet
Author: User
Tags hmac

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.