TypeError: Unicode-objects must be encoded before hashing

来源:互联网 发布:linux读取文件指定行 编辑:程序博客网 时间:2024/06/06 14:29
[python] view plain copy
  1. import hashlib  
  2. import sys  
  3.   
  4. def vic_md5():  
  5.     m=hashlib.md5()  
  6.     strs=sys.argv[1]  
  7.     m.update(strs.encode("utf8"))  # update()必须指定要加密的字符串的字符编码
  8.     print(m.hexdigest())  
  9.   
  10. if __name__=='__main__':  
  11.   
  12.     vic_md5()  
阅读全文
0 0