Skip to content

@kieranbenton /ECDSA.cs secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
ECDSA in C#
void Main()
{
byte[] publickey;
byte[] data;
byte[] signature;
using (var dsa = new ECDsaCng(256))
{
dsa.HashAlgorithm = CngAlgorithm.Sha256;
publickey = dsa.Key.Export(CngKeyBlobFormat.EccPublicBlob);
data = new byte[] { 21, 5, 8, 12, 207 };
signature = dsa.SignData(data);
}
signature.Length.Dump();
Convert.ToBase64String(signature).Dump();
using (ECDsaCng ecsdKey = new ECDsaCng(CngKey.Import(publickey, CngKeyBlobFormat.EccPublicBlob)))
{
if (ecsdKey.VerifyData(data, signature))
Console.WriteLine("Data is good");
else
Console.WriteLine("Data is bad");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.