Python bulk MD5 encryption __python

Source: Internet
Author: User
Tags gz file md5 encryption

The tool is a Anaconda Python software tool, because it contains a Python statement and contains many statistical functions


2, the specific use of steps
1 database data exported into a CSV file, which has to be MD5 encrypted fields
2) CSV import into Python
3) Load MD5 function
4) for MD5 encryption
5) Export Encrypted data


What is MD5?

MD5 is a hash function widely used in the field of computer security to provide integrity protection for messages.

In the 1991, Rivest developed a more sophisticated MD5 algorithm. It adds the concept of "security-straps" (safety-belts) on the basis of MD4. Although MD5 is more complex than MD4, it is more secure. This algorithm is clearly composed of four and MD4 designs with a few different steps. In the MD5 algorithm, the size of the information-digest and the necessary conditions for filling are exactly the same as the MD4. Den Boer and Bosselaers have discovered a fake conflict (pseudo-collisions) in the MD5 algorithm, but there are no other encrypted results found.

What's the role of MD5?

A typical application is to generate a summary of information (message-digest) for a piece of information (message) to prevent tampering. For example, there are a lot of software downloads on Unix with a file name that has the same filename, file name extension. md5 files, in which there is usually only one line of text, roughly structured like this:

MD5 (tanajiya.tar.gz) = 0ca175b9c0f726a831d895e269332461

This is the digital signature of the tanajiya.tar.gz file. MD5 the whole file as a large text information, through its irreversible string transformation algorithm, produced this unique MD5 information digest. In order for readers to have an intuitive understanding of the application of MD5, the author uses an analogy and an example to briefly describe its work process:

As you all know, anyone on earth has a unique fingerprint. This is often the most trustworthy way for the judiciary to identify criminals; Similarly, MD5 can produce an equally unique "digital fingerprint" for any file (regardless of size, format, quantity), if anyone changes the file, The MD5 value of the corresponding "digital fingerprint" will be changed.

To encrypt a single field first:

Import Hashlib 
m=hashlib.md5 () 


#单个md5加密 
d= ' 1dsadad33 ' 
type (d) 
#m. Update (d) 
#在进行md5哈希计算前 , the data needs to be encoded. Data must be converted to the bytes type 
#方法可是d. Encode ("UTF8"), in addition to UTF8, gb2312, MBCS, Unicode_escape, and M.update 
(D.encode ("UTF8")) 
Psw=m.hexdigest () 




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.