Python Forum

Full Version: SHA256 ImportError when using Crypto.Hash in crypto.py
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys.

I'm getting an ImportError for 'SHA256' when using Crypto.Hash in crypto.py

crypto.py includes:
from Crypto.Hash import (
    SHA256 as _sha256,
    SHA512 as _sha512,
)
def SHA256(x: bytes) -> bytes:
    return _sha256.new(x).digest()
I'm using Python 3.11.2 on Raspberry PI 5.

According to my web searches, this is caused by pycryptodome...

I uninstalled and then reinstalled (using pip3) pycryptodome but that didn't help...

Any ideas?
https://www.pycryptodome.org/src/introduction
Quote:an almost drop-in replacement for the old PyCrypto library. You install it with

...

One must avoid having both PyCrypto and PyCryptodome installed at the same time, as they will interfere with each other.

Uninstall both, then reinstall PyCryptodome.
PyCrypto is no longer maintained.