Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23160

raise ValueError("RSA key format is not supported") Convert a string into RSA Key Python

$
0
0

I am trying to create a RSA publickey with a text that is entered by user. I use Cryptodomex library. Although I have used PEM to create a string in PEM format, it did not work and there was an error ValueError("RSA key format is not supported").

I have tried adding more blank spaces to make the key long-enough. However, it still did not work.

from Crypto.PublicKey import RSAfrom Crypto.Cipher import PKCS1_OAEPimport base64from Crypto.IO import PEMpublic_key = 'PUBPUB'# public_key += (2048 - len(public_key)) * ''public_key = PEM.encode(public_key.encode(), 'PUBLIC KEY')print(public_key)rsa_key = RSA.import_key(public_key.encode())

Viewing all articles
Browse latest Browse all 23160

Trending Articles