本文整理匯總了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");
}
}
}