import hashlib m = hashlib.md5(b'123') # b代表bytes型 m0 = hashlib.md5(b'abc') mi = m.hexdigest() mi0 = m0.hexdigest() print(mi) print(mi0)
对于中文,则进行转码:
import hashlib data='你好' m = hashlib.md5(data.encode('gb2312')) mi = m.hexdigest() --------------------------------------------------- m0 = hashlib.md5(data.encode('utf8')) mi0 = m.hexdigest() print(mi) print(mi0)
#!/usr/bin/python
import hashlib m = hashlib.md5() m.update(b'admin+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+1638170157') m_out=m.hexdigest() print(m_out)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)