本文整理汇总了C#中Seed.Export方法的典型用法代码示例。如果您正苦于以下问题:C# Seed.Export方法的具体用法?C# Seed.Export怎么用?C# Seed.Export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Seed
的用法示例。
在下文中一共展示了Seed.Export方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHash
public static byte[] GetHash(Seed seed)
{
return _caches.GetValue(seed,
(_) =>
{
var swap = new Seed();
lock (seed.ThisLock)
{
swap.Rank = seed.Rank;
swap.Key = seed.Key;
swap.CompressionAlgorithm = seed.CompressionAlgorithm;
swap.CryptoAlgorithm = seed.CryptoAlgorithm;
swap.CryptoKey = seed.CryptoKey;
}
using (var stream = swap.Export(BufferManager.Instance))
{
return Sha256.ComputeHash(stream);
}
});
}
示例2: Test_Seed
public void Test_Seed()
{
foreach (var a in new DigitalSignatureAlgorithm[] { DigitalSignatureAlgorithm.Rsa2048_Sha256, DigitalSignatureAlgorithm.EcDsaP521_Sha256 })
{
var seed = new Seed();
seed.Name = "aaaa.zip";
seed.Keywords.AddRange(new KeywordCollection
{
"bbbb",
"cccc",
"dddd",
});
seed.CreationTime = DateTime.Now;
seed.Length = 10000;
seed.Comment = "eeee";
seed.Rank = 1;
seed.Key = new Key(new byte[32], HashAlgorithm.Sha256);
seed.CompressionAlgorithm = CompressionAlgorithm.Xz;
seed.CryptoAlgorithm = CryptoAlgorithm.Aes256;
seed.CryptoKey = new byte[32 + 32];
DigitalSignature digitalSignature = new DigitalSignature("123", a);
seed.CreateCertificate(digitalSignature);
var seed2 = seed.Clone();
Assert.AreEqual(seed, seed2, "Seed #1");
Seed seed3;
using (var seedStream = seed.Export(_bufferManager))
{
seed3 = Seed.Import(seedStream, _bufferManager);
}
Assert.AreEqual(seed, seed3, "Seed #2");
Assert.IsTrue(seed3.VerifyCertificate(), "Seed #3");
}
}