本文整理汇总了C#中System.Security.Cryptography.ECDsaCng类的典型用法代码示例。如果您正苦于以下问题:C# ECDsaCng类的具体用法?C# ECDsaCng怎么用?C# ECDsaCng使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ECDsaCng类属于System.Security.Cryptography命名空间,在下文中一共展示了ECDsaCng类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
class Alice
{
public static void Main(string[] args)
{
Bob bob = new Bob();
using (ECDsaCng dsa = new ECDsaCng())
{
dsa.HashAlgorithm = CngAlgorithm.Sha256;
bob.key = dsa.Key.Export(CngKeyBlobFormat.EccPublicBlob);
byte[] data = new byte[] { 21, 5, 8, 12, 207 };
byte[] signature = dsa.SignData(data);
bob.Receive(data, signature);
}
}
}
public class Bob
{
public byte[] key;
public void Receive(byte[] data, byte[] signature)
{
using (ECDsaCng ecsdKey = new ECDsaCng(CngKey.Import(key, CngKeyBlobFormat.EccPublicBlob)))
{
if (ecsdKey.VerifyData(data, signature))
Console.WriteLine("Data is good");
else
Console.WriteLine("Data is bad");
}
}
}