Hashlib module and Pythonhashlib module in Python

Source: Internet
Author: User

Hashlib module and Pythonhashlib module in Python
Hashlib module in Python

This module is mainly used for data encryption. Encryption methods include md5, sha1_, sha384, sha512, sha1, sha3_224, sha3_256, sha3_384, and sha3_512. It converts data of any length into a fixed-length data string (usually expressed in hexadecimal strings) through a function ). Different encryption methods are used in the same way. Therefore, only the md5 encryption code is used here:

ImportHashlib

M = hashlib. md5 ()

M. update ('Hello'. Encode ('Utf8') # Encrypt the data 'hello' using md5

Print ('m = ', m. hexdigest () # print the encrypted result in hexadecimal notation. M = 5d41402abc4b2a76b9719d911017c592

B. update ('He'. Encode ('Utf8'))

B. update ('Llo'. Encode ('Utf8'))

Print ('B =', B. hexdigest () # perform step-by-step encryption and direct encryption. The result is the same as that of. B = 5d41402abc4b2a76b9719d911017c592.

 

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.