import hashlib
phone_num = open("D:/testdata/phone10.txt","r")
out_file = open("D:/testdata/after_md5.txt", "w")
md5 = hashlib.md5()
for line in phone_num:
md5.update(line.encode('utf-8'))
r = md5.hexdigest()
out_file.write(r+'\n')
out_file.close()
Copy the code