0

I'm using pycryptodome library to do hashing. I tried SHA using pycryptodome.

from Crypto.Hash import SHA256

mess = b'hello'
h = SHA256.new(mess)
print(h.hexdigest())

This is the code I'm using but is giving me errors.

Traceback (most recent call last):
  File "/Users/thekc/PycharmProjects/MS_CS/Misc/ANS/roughwork.py", line 4, in <module>
    h = SHA256.new(mess)

  File "/Users/thekc/PycharmProjects/MS_CS/venv/lib/python3.9/site-packages/Crypto/Hash/SHA256.py", line 158, in new
    return SHA256Hash().new(data)

  File "/Users/thekc/PycharmProjects/MS_CS/venv/lib/python3.9/site-packages/Crypto/Hash/SHA256.py", line 73, in __init__
    result = _raw_sha256_lib.SHA256_init(state.address_of())

  File "/Users/thekc/PycharmProjects/MS_CS/venv/lib/python3.9/site-packages/cffi/api.py", line 912, in __getattr__
    make_accessor(name)

  File "/Users/thekc/PycharmProjects/MS_CS/venv/lib/python3.9/site-packages/cffi/api.py", line 908, in make_accessor
    accessors[name](name)

  File "/Users/thekc/PycharmProjects/MS_CS/venv/lib/python3.9/site-packages/cffi/api.py", line 838, in accessor_function
    value = backendlib.load_function(BType, name)

AttributeError: function/symbol 'SHA256_init' not found in library '/Users/thekc/PycharmProjects/MS_CS/venv/lib/python3.9/site-packages/Crypto/Util/../Hash/_SHA256.cpython-39-darwin.so': dlsym(0x88adddf0, SHA256_init): symbol not found

Process finished with exit code 1
Michael Ruth
  • 2,938
  • 1
  • 20
  • 27
Krishna
  • 1
  • 1
  • May be a version issue. Check out this Github [issue](https://github.com/pycrypto/pycrypto/issues/233), and SO [question](https://stackoverflow.com/q/66226983/4583620). Which version are you using while generating this error? – Michael Ruth May 02 '23 at 15:49
  • Uninstall the library and then install. There are two libraries with the same name - remove one so that you can install the other. – John Hanley May 02 '23 at 18:09

0 Answers0