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('\n')

pwdFile.close()
md5File.close()

輸出結果:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM