RSA decryption error

Hi!

My code:

RSA1:= TRSAEncSign.Create(nil);
RSA1.KeyLength := kl2048;
RSA1.encType := oaep;
RSA1.hashFunction := TRSAhashfunction.sha256;
RSA1.OutputFormat := base64;
RSA1.Unicode := yesUni;
RSA1.FromPrivateKeyFile('D:\TMSCryptoSetupReg\private_key.pem');
Memo1.Text := RSA1.Decrypt(//encrypted text in base64//);
RSA1.Free;

I get an error:

Debugger Exception Notification

Project Test.exe raised exception class ECryptoPack with message 'error : in RSA OAEP, the decryption fails!'.

How to fix it?
Thanks

Hi, most likely a format issue. Did you decrypt your PEM private key before using it?

Hi,

How and to what format should the Private Key be converted?

RAS encryption is obtained in this way:
RSA1.FromPuplicKeyFile('D:\TMSCryptoSetupReg\public_key.pem');
RSA1.Decrypt( ......

Thanks

in the last post I meant
RSA1.Encrypt( ......

I also encrypted it like this:
RSA1.FromPuplicKey('MIIBIjANBgkqhkiG9w0B1298211s2AQEFAA.................');
RSA1.Encrypt( ...
I didn't prepare the key at all,
I used from PEM file as is.

Decryption won't work like that?

Thanks.