Python实现批量MD5加密

#!/usr/bin/python
# -*- coding: utf-8 -*-
import hashlib

def md5(str):
    hl = hashlib.md5()
    hl.update(str.encode(encoding='utf-8'))
    return hl.hexdigest()

pwdFile = open('password')  # 源文件
pwd = pwdFile.readlines()
md5File = open('md5Password.txt', 'w')  # 目标文件

print(pwd)
for p in pwd:
    print(md5(p.strip()))  # 去除尾部的换行符
    md5File.write(md5(p.strip()))
    md5File.write('
')

pwdFile.close()
md5File.close()

输出结果:

原文地址:https://www.cnblogs.com/oeong/p/12850002.html