Python in hashlib module

Source: Internet
Author: User

Python in hashlib module

This module is mainly used for data encryption. Encryption methods include MD5, sha224, sha384, sha512, SHA1, sha3_224, sha3_256, sha3_384, sha3_512, and so on. It uses a function to convert any length of data into a fixed length data string (usually represented by a 16-binary string). The use of different encryption methods is the same, so in this case only the code with MD5 encryption:

Import Hashlib

m = Hashlib.md5 ()

M.update (' Hello '. Encode (' UTF8 ')) #对数据 ' Hello ' for MD5 encryption

Print (' m= ', M.hexdigest ()) #以十六进制数将加密后的结果打印出来. M= 5d41402abc4b2a76b9719d911017c592

B.update ('he 'encode ('UTF8 '))

B.update ('llo'. Encode ('UTF8 '))

Print (' b= ', B.hexdigest ()) #分步加密和直接加密 as a result. b= 5d41402abc4b2a76b9719d911017c592

Python in hashlib module

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.