Mandar Bhale
Mandar Bhale

Reputation: 11

Default_backend not defined in cryptography-RSA (python)

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.

Upvotes: 1

Views: 2927

Answers (1)

Yilmaz
Yilmaz

Reputation: 49521

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()
        

Upvotes: 1

Related Questions