一、获取大文件的MD5值

 

import os
import hashlib

def get_file_md5(path):
    file_size = os.path.getsize(path)
    md5 = hashlib.md5()
    with open(path,'rb')as f:
        while file_size > 2048:
            content = f.read(2048)
            md5.update(content)
            file_size -= 2048
        else:
            content = f.read()
            if content:
                md5.update(content)
    return md5.hexdigest()

二、登陆的用户名及密码生成密文

 

import hashlib

def get_md5(username,password):
    # 加盐
    md5 = hashlib.md5(username.encode('utf-8'))
    # 利用之前的盐与密码生成密文
    md5.update(password.encode('utf-8'))
    # 最终生成密文
    return md5.hexdigest()

 

相关文章:

  • 2022-12-23
  • 2021-07-19
猜你喜欢
  • 2021-11-02
  • 2021-08-29
相关资源
相似解决方案