一、关于字符串转为二进制数据的方法
方法:
b'hello' 与 ‘hello’.encode('utf-8') 作用相同
import hashlib md = hashlib.md5() # 生成一个造密文的对象 val = '啦啦啦啦' # 加盐处理 md.update(val.encode('utf-8')) # md.update('hello'.encode('utf-8')) # 将字符串转为二进制形式 md.update(b'hello') # Bytes类型也就是二进制形式, b'hello' 与 'hello'.encode('utf-8') 作用是一样的 res = md.hexdigest() print(res)