本文整理汇总了C#中System.Security.Cryptography.DSACryptoServiceProvider.ExportCspBlob方法的典型用法代码示例。如果您正苦于以下问题:C# DSACryptoServiceProvider.ExportCspBlob方法的具体用法?C# DSACryptoServiceProvider.ExportCspBlob怎么用?C# DSACryptoServiceProvider.ExportCspBlob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.DSACryptoServiceProvider
的用法示例。
在下文中一共展示了DSACryptoServiceProvider.ExportCspBlob方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateSigningKey
public UpdateSigningKey()
{
DSACryptoServiceProvider provider = new DSACryptoServiceProvider();
PrivateKey = provider.ExportCspBlob(true);
PublicKey = provider.ExportCspBlob(false);
Name = "New Key";
}
示例2: GenerateSignKeyPair
public static SignKeys GenerateSignKeyPair()
{
SignKeys keys = new SignKeys();
using (DSACryptoServiceProvider dsa = new DSACryptoServiceProvider())
{
keys.PublicAndPrivate = dsa.ExportCspBlob(true);
keys.PublicOnly = dsa.ExportCspBlob(false);
}
return keys;
}
示例3: Main
//--- Class Methods ---
static void Main(string[] args) {
Console.WriteLine("MindTouch KeyGen, Copyright (c) 2006-2010 MindTouch Inc.");
Console.WriteLine();
// generate keys
DSACryptoServiceProvider crypto = new DSACryptoServiceProvider();
Console.WriteLine();
Console.WriteLine("Digital Signature Keys");
Console.WriteLine("----------------------");
Console.WriteLine("Private: " + Convert.ToBase64String(crypto.ExportCspBlob(true)));
Console.WriteLine("Public : " + Convert.ToBase64String(crypto.ExportCspBlob(false)));
}
示例4: CreateKeysButton_Click
private void CreateKeysButton_Click(object sender, RoutedEventArgs e)
{
DSACryptoServiceProvider provider = new DSACryptoServiceProvider();
string privateKeyFile = Convert.ToBase64String(provider.ExportCspBlob(true));
string publicKeyFile = Convert.ToBase64String(provider.ExportCspBlob(false));
string privateFileName, publicFileName;
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = "Sparkle Private Key File|*.sparklePrivateKey";
dialog.Title = "Please choose a location for your Private Key";
dialog.FileName = "Update Signing Private Key";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) {
return;
}
privateFileName = dialog.FileName;
if (String.IsNullOrEmpty(privateFileName)) {
return;
}
dialog = new SaveFileDialog();
dialog.Filter = "Sparkle Public Key File|*.sparklePublicKey";
dialog.Title = "Please choose a location for your Public Key";
dialog.FileName = "Update Signing Public Key";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) {
return;
}
publicFileName = dialog.FileName;
if (String.IsNullOrEmpty(publicFileName)) {
return;
}
try {
File.WriteAllText(privateFileName, privateKeyFile, Encoding.UTF8);
File.WriteAllText(publicFileName, publicKeyFile, Encoding.UTF8);
} catch (Exception ex) {
System.Windows.MessageBox.Show(String.Format("File could not be saved: {0}", ex.Message));
return;
}
}
示例5: ImportCspBlob_Keypair
public void ImportCspBlob_Keypair ()
{
byte[] blob = new byte [336] { 0x07, 0x02, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x44, 0x53, 0x53, 0x32, 0x00, 0x04, 0x00, 0x00, 0xD3,
0x7B, 0xC6, 0xED, 0x3F, 0x72, 0x44, 0xBD, 0x22, 0x7D, 0xF2, 0xD4, 0x62, 0xFE, 0x7C, 0xE3, 0x75, 0x8F, 0x9C, 0xDE, 0x69, 0xC0, 0x3A,
0x0C, 0xE6, 0x26, 0x5A, 0x46, 0x3D, 0xEF, 0x0D, 0x90, 0x20, 0xC6, 0xF6, 0x45, 0x7C, 0x73, 0xE8, 0xB9, 0x7D, 0x86, 0x27, 0xF7, 0x97,
0x76, 0xC8, 0x1C, 0x8E, 0x8B, 0xCE, 0x26, 0x93, 0xE6, 0x21, 0x53, 0x20, 0x93, 0x58, 0x25, 0x45, 0x1C, 0x46, 0x66, 0x17, 0x10, 0x98,
0x03, 0x96, 0xD0, 0xE5, 0xC8, 0x30, 0x80, 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 0x73, 0x21, 0x78, 0x0F, 0xD5, 0x0F, 0xB0,
0xEB, 0x76, 0x41, 0xF1, 0x23, 0x7A, 0x6A, 0x78, 0xCC, 0x4F, 0x3D, 0xB1, 0x2F, 0x0A, 0xF6, 0x9A, 0xA7, 0x18, 0xC1, 0x2F, 0xF0, 0xB7,
0x73, 0x91, 0x51, 0x6D, 0x9B, 0xB5, 0xB2, 0x03, 0x7C, 0xE0, 0x00, 0x00, 0x00, 0x9B, 0xAF, 0x1B, 0xE9, 0xC1, 0xC7, 0x35, 0xF5, 0xE2,
0xEB, 0xC9, 0xEE, 0xF6, 0xBA, 0x25, 0x6D, 0x6F, 0x39, 0x83, 0xB9 };
dsa = new DSACryptoServiceProvider (minKeySize);
dsa.ImportCspBlob (blob);
byte[] keypair = dsa.ExportCspBlob (true);
for (int i = 0; i < blob.Length; i++)
Assert.AreEqual (blob[i], keypair[i], i.ToString ());
}
示例6: ExportCspBlob_MissingPrivateKey_PublicOnly
public void ExportCspBlob_MissingPrivateKey_PublicOnly ()
{
dsa = new DSACryptoServiceProvider (minKeySize);
DSAParameters dsap = AllTests.GetKey (false);
dsa.ImportParameters (dsap);
byte[] pubkey = dsa.ExportCspBlob (false);
Assert.AreEqual ("06-02-00-00-00-22-00-00-44-53-53-31-00-04-00-00-D3-7B-C6-ED-3F-72-44-BD-22-7D-F2-D4-62-FE-7C-E3-75-8F-9C-DE-69-C0-3A-0C-E6-26-5A-46-3D-EF-0D-90-20-C6-F6-45-7C-73-E8-B9-7D-86-27-F7-97-76-C8-1C-8E-8B-CE-26-93-E6-21-53-20-93-58-25-45-1C-46-66-17-10-98-03-96-D0-E5-C8-30-80-72-B6-49-B3-82-95-B3-8D-3A-A5-E5-60-C6-42-3A-33-70-67-30-C5-1C-32-D9-EB-CF-C1-36-B3-F3-24-07-39-86-0D-E9-12-80-73-26-A7-8C-8B-8A-40-AA-51-43-8F-20-DE-D2-9C-F3-B3-51-73-83-62-A0-11-C9-50-93-E1-F0-64-BE-D0-9E-E0-5B-13-47-AA-56-65-62-47-FD-3A-94-B7-1B-E5-35-95-86-14-64-C0-D6-07-96-4C-55-1E-0A-4C-10-C2-B5-E6-FB-74-F9-A5-72-E0-42-96-62-0B-EF-B7-52-36-7D-E3-01-12-85-E6-FE-92-75-40-C2-A6-D0-9D-16-6F-C1-C7-A7-DF-48-80-A2-5D-A0-FD-84-BE-06-AC-CB-32-22-82-D2-D7-7C-69-FC-BC-94-78-2B-11-5B-1C-1E-AF-DB-7A-AA-31-F3-D8-74-84-00-3F-9D-B9-4B-B2-68-7E-F4-1B-C2-83-73-21-78-0F-D5-0F-B0-EB-76-41-F1-23-7A-6A-78-CC-4F-3D-BB-C7-03-89-C4-0B-66-86-80-D5-AA-34-E8-14-71-F9-29-BE-B9-EE-34-B1-5F-A2-C8-4D-CD-CF-0E-8E-A4-2E-D4-65-8C-27-FF-C1-41-26-F9-0E-E5-11-C9-CC-3E-45-87-EC-49-BA-7C-83-91-DE-70-E8-27-1C-47-EB-1D-E2-37-62-2F-AA-5B-30-80-8B-80-00-55-F4-64-C2-BE-5A-D3-54-4A-E7-0B-95-00-F4-BA-72-CD-F8-22-E6-30-4E-F6-BD-BE-3F-00-52-7F-E2-57-5F-C0-BE-82-C0-50-07-1C-7D-89-56-49-CE-28-52-8C-11-B1-D1-51-51-12-B2-E0-00-00-00-9B-AF-1B-E9-C1-C7-35-F5-E2-EB-C9-EE-F6-BA-25-6D-6F-39-83-B9", BitConverter.ToString (pubkey));
}
示例7: ExportCspBlob_MissingPrivateKey
public void ExportCspBlob_MissingPrivateKey ()
{
dsa = new DSACryptoServiceProvider (minKeySize);
DSAParameters dsap = AllTests.GetKey (false);
dsa.ImportParameters (dsap);
dsa.ExportCspBlob (true);
}
示例8: ExportCspBlob_PublicKey
public void ExportCspBlob_PublicKey ()
{
byte[] blob = new byte [444] { 0x06, 0x02, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x44, 0x53, 0x53, 0x31, 0x00, 0x04, 0x00,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CD, 0xF8, 0x22, 0xE6, 0x30, 0x4E, 0xF6, 0xBD, 0xBE,
0x3F, 0x00, 0x52, 0x7F, 0xE2, 0x57, 0x5F, 0xC0, 0xBE, 0x82, 0xC0, 0x50, 0x07, 0x1C, 0x7D, 0x89, 0x56, 0x49, 0xCE, 0x28, 0x52, 0x8C,
0x11, 0xB1, 0xD1, 0x51, 0x51, 0x12, 0xB2, 0xE0, 0x00, 0x00, 0x00, 0x9B, 0xAF, 0x1B, 0xE9, 0xC1, 0xC7, 0x35, 0xF5, 0xE2, 0xEB, 0xC9,
0xEE, 0xF6, 0xBA, 0x25, 0x6D, 0x6F, 0x39, 0x83, 0xB9 };
dsa = new DSACryptoServiceProvider (minKeySize);
dsa.ImportCspBlob (blob);
byte[] pubkey = dsa.ExportCspBlob (false);
for (int i = 0; i < blob.Length; i++)
AssertEquals (i.ToString (), blob [i], pubkey [i]);
}