23 lines
662 B
C#
23 lines
662 B
C#
using DigitalData.Core.Abstractions.Security;
|
|
|
|
namespace DigitalData.Core.Security.RSAKey
|
|
{
|
|
public class RSAPublicKey : RSAKeyBase, IAsymmetricPublicKey, IAsymmetricKey
|
|
{
|
|
public override string Pem
|
|
{
|
|
get => base.Pem;
|
|
init
|
|
{
|
|
base.Pem = value;
|
|
RSA.ImportFromPem(value);
|
|
}
|
|
}
|
|
|
|
public byte[] Encrypt(byte[] data) => RSA.Encrypt(data, Padding);
|
|
|
|
public string Encrypt(string data) => RSA.Encrypt(data.ToBytes(), Padding).ToBase64String();
|
|
|
|
public bool Verify(string data, string signature) => Encrypt(data) == signature;
|
|
}
|
|
} |