# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import hashlib,bs4,requests
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
content="admin007"
#md5="21232f297a57a5a743894a0e4a801fc3"
url="http://md5decryption.com/"
def MD5_encryption(content):
m=hashlib.md5()
byte_content=content.encode('utf-8')
m.update(byte_content)
md5_encrypted_content=m.hexdigest() #返回摘要,作为十六进制数据字符串值
return md5_encrypted_content
def MD5_decryption(md5):
browser = webdriver.Firefox()
browser.get(url)
elem=browser.find_element_by_name('hash')
elem.send_keys(md5)
#相当于提交点击
elem.send_keys(Keys.RETURN)
decryption_elem=browser.find_element_by_class_name("main")
content=decryption_elem.text
list1=content.split("\n\n\n\n")
decryption=list1[2]
#print (decryption)
decryption1=decryption.split(":")
decrpytion_text=decryption1[1].strip()
browser.close()
browser.quit()
return decrpytion_text
md5=MD5_encryption(content)
original_content=MD5_decryption(md5)
print ("md5:",md5)
print ("original_content:",original_content)