Trismegistos
Trismegistos

Reputation: 31

While trying to run cryptocode I get the error: "module 'hashlib' has no attribute 'scrypt'"

As I mentioned in the title Im trying to run the library cryptocode by using this simple code:

import cryptocode

password = "This is a test"
key = "My Key"


def encrypt(password, key):
    return cryptocode.encrypt(password, key)


def decrypt(encryptetpass):
    return cryptocode.decrypt(encryptetpass, key)


encrypted_pass = encrypt(password, key)
print(encrypted_pass)

print(decrypt(encrypted_pass))

While running it locally on Windows I get no errors, but trying the same on Linux generates me the previously in the title mentioned error:

(venv) pwd$ python3.9 crypt_test.py

Traceback (most recent call last):
  File "/crypt_test.py", line 15, in <module>
    encrypted_pass = encrypt(password, key)
  File "/crypt_test.py", line 8, in encrypt
    return cryptocode.encrypt(password, key)
  File "/venv/lib/python3.9/site-packages/cryptocode/myfunctions.py", line 16, in encrypt
    private_key = hashlib.scrypt(
AttributeError: module 'hashlib' has no attribute 'scrypt'

I tried updating Openssl, reinstalled my venv and Python.

Upvotes: 3

Views: 3182

Answers (2)

Swapnil Pathare
Swapnil Pathare

Reputation: 69

check below points:

To check which all versions are installed

which python

//use python or python3 as per your needs

To check where all versions are installed

where python

//use python or python3 as per your needs

In mycase i was having two paths as below,

/usr/bin/python 
/usr/local/bin/python

so, now check VS Code,

  • Command + Shipt + P
  • Search/Select Python Interpreter
  • select appropriate version you are using, if not listed Add the respective path and select the same.

This Solution worked for me:)

Upvotes: 1

gdavid7
gdavid7

Reputation: 291

Did you try to build the latest OpenSSL? I see instructions here: https://www.howtoforge.com/tutorial/how-to-install-openssl-from-source-on-linux/ (wasn't able to try this because I'm not running Linux). Please let us know if this worked.

Upvotes: 0

Related Questions