Python MD5 encryption

http://hi.baidu.com/gavensun_wang/item/c93636be34ef4c56ba0e12cb

Python achieve MD5 encryption is done through hashlib. In the demo, we first create a text as an encrypted data. As shown below: hashlib_data.py

#--encoding='utf-8'--

import hashlib

lorem=""" Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donecegestas, enim et consectetuer ullamcorper, lectus ligula rutrum leo,a elementum elit tortor eu quam. Duis tincidunt nisi ut ante. Nullafacilisi. Sed tristique eros eu libero. Pellentesque velarcu. Vivamus purus orci, iaculis ac, suscipit sit amet, pulvinar eu,lacus. Praesent placerat tortor sed nisl. Nunc blandit diam egestasdui. Pellentesque habitant morbi tristique senectus et netus etmalesuada fames ac turpis egestas. Aliquam viverra fringillaleo. Nulla feugiat augue eleifend nulla. Vivamus mauris. Vivamus sedmauris in nibh placerat egestas. Suspendisse potenti. Maurismassa. Ut eget velit auctor tortor blandit sollicitudin. Suspendisseimperdiet justo. """

The use of MD5 encryption simply call the hashlib in the MD5 encryption algorithm.:

#--encoding='utf-8'--

import hashlib from hashlib_data

import lorem

h=hashlib.md5()

h.update(lorem)

print h.hexdigest()

h=hashlib.md5()MD5 encryption is used to create objects;

h.update(lorem)The lorem character is encrypted using the MD5 algorithm. The output results as follows:

913fa23cc9326eb26f62859c9feed3e4

Posted by Krystal at November 18, 2013 - 9:48 AM