1

I am getting default_backend is not defined error while using RSA algorithm from hazmat in python 3.5 . Can anyone solve my problem ? The problem occurs while creating private key for rsa algorithm using cryptography module in python.

2
  • Did you use module.func or func? If the first you need to have written from module import func else you need the module prefix after using import module can you show us your code, please? Commented Oct 9, 2018 at 5:48
  • You must show your code if you want help debugging it. It's one of our rules. Commented Oct 9, 2018 at 13:45

1 Answer 1

1

you should have post your code to tell you your mistake. I think you are not passing the default_backend to ec to generate the private key. here is the implementation:

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import ec

class Wallet:
    def __init__(self):
        
        # SECP=standard efficient cryptography prime. prime is used to genereate the curve
        # that prime number is 256 bit, K=kobler, 1 stands for first
        self.private_key=ec.generate_private_key(ec.SECP256K1(), default_backend())
        self.public_key=self.private_key.public_key()
        
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.