26 lines
671 B
C#
26 lines
671 B
C#
namespace DigitalData.Core.Security
|
|
{
|
|
public class RSADecryptor : RSACryptographer
|
|
{
|
|
public required string PrivateKeyPem
|
|
{
|
|
init => _rsa.ImportFromPem(value);
|
|
}
|
|
|
|
public RSAEncryptor Encryptor
|
|
{
|
|
get
|
|
{
|
|
return new ()
|
|
{
|
|
PublicKeyPem = _rsa.ExportRSAPublicKeyPem(),
|
|
Padding = Padding
|
|
};
|
|
}
|
|
}
|
|
|
|
public byte[] Decrypt(byte[] data) => _rsa.Decrypt(data, Padding);
|
|
|
|
public string Decrypt(string data) => _rsa.Decrypt(data.Base64ToByte(), Padding).BytesToString();
|
|
}
|
|
} |