0

I got errors like this. I am trying to hash a sha256 file in Python.

I got an error like this I don't know why, how can I fix the command line?

>>> import hashlib
>>> with open("realuniq.lst") as f:
...     with open("file.txt", "w") as outfile:
...         for line in f:
...             line = line.strip()
...             hash = hashlib.sha256(line.encode()).hexdigest()
...             outfile.write(hash + "\n")
...
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/usr/lib/python3.8/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 237: invalid continuation byte
halfer
  • 19,824
  • 17
  • 99
  • 186
hai long
  • 11
  • 3
  • at the 322 line where I hash the sha256 it's like this: !!!iLOVEpaka!!! – hai long Sep 03 '22 at 16:03
  • why is it that when i use the crackstation wordlist it fails to bruteforce but when i create my own wordlist it works perfectly – hai long Sep 03 '22 at 16:20
  • It looks like you are constructing UTF-8 strings using sequences of bytes. Not all byte combinations are valid, and Python is telling you that your string was invalid. – halfer Sep 03 '22 at 17:09
  • thanks you ;;It looks like you are constructing UTF-8 strings using sequences of bytes. Not all byte combinations are valid, and Python is telling you that your string was invalid. – hai long Sep 04 '22 at 01:57

0 Answers0