Cześć,
Mam taki problem z skracniem tekstu z pliku funkcją skrótu. Ktoś podpowie dlaczego to nie chce działać? Z góry dzięki za pomoc.
def hash_data_using_SHA512(data):
hasher = SHA512.new()
hasher.update(data)
return hasher.hexdigest()
text = czytaj_plik("plik.txt")
print("Text z pliku: ", text)
print (type(text))
h = SHA512.new()
h.update(text)
print(h.hexdigest())
<class 'str'>
Traceback (most recent call last):
File "C:\Users\Marcin\Desktop\bsk\lab5.py", line 24, in <module>
h.update(text)
File "C:\Users\Marcin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\Crypto\Hash\SHA512.py", line 103, in update
c_uint8_ptr(data),
File "C:\Users\Marcin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\Crypto\Util\_raw_api.py", line 232, in c_uint8_ptr
raise TypeError("Object type %s cannot be passed to C code" % type(data))
TypeError: Object type <class 'str'> cannot be passed to C code