相关疑难解决方法(0)

如何纠正TypeError:必须在散列之前编码Unicode对象?

我有这个错误:

Traceback (most recent call last):
  File "python_md5_cracker.py", line 27, in <module>
  m.update(line)
TypeError: Unicode-objects must be encoded before hashing
Run Code Online (Sandbox Code Playgroud)

当我尝试在Python 3.2.2中执行此代码时:

import hashlib, sys
m = hashlib.md5()
hash = ""
hash_file = input("What is the file name in which the hash resides?  ")
wordlist = input("What is your wordlist?  (Enter the file name)  ")
try:
  hashdocument = open(hash_file, "r")
except IOError:
  print("Invalid file.")
  raw_input()
  sys.exit()
else:
  hash = hashdocument.readline()
  hash = hash.replace("\n", "")

try:
  wordlistfile = open(wordlist, …
Run Code Online (Sandbox Code Playgroud)

python unicode syntax-error hashlib python-3.x

256
推荐指数
9
解决办法
27万
查看次数

标签 统计

hashlib ×1

python ×1

python-3.x ×1

syntax-error ×1

unicode ×1