本文整理汇总了C#中Org.BouncyCastle.Security.SecureRandom.SetSeed方法的典型用法代码示例。如果您正苦于以下问题:C# SecureRandom.SetSeed方法的具体用法?C# SecureRandom.SetSeed怎么用?C# SecureRandom.SetSeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Org.BouncyCastle.Security.SecureRandom
的用法示例。
在下文中一共展示了SecureRandom.SetSeed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateNewMachineKey
private static SecureString GenerateNewMachineKey(int keySize)
{
var random = new SecureRandom();
random.SetSeed(random.GenerateSeed(128));
var machineKeyString = "";
for (var x = 0; x < keySize; x++)
{
machineKeyString += (char)random.Next(33, 126);
}
return machineKeyString.ConvertToSecureString();
}
示例2: RandMult
private void RandMult(string label, X9ECParameters spec)
{
ECCurve C = spec.Curve;
ECPoint G = (ECPoint)spec.G;
BigInteger n = spec.N;
SecureRandom random = new SecureRandom();
random.SetSeed(DateTimeUtilities.CurrentUnixMs());
Console.WriteLine(label);
int[] coords = ECCurve.GetAllCoordinateSystems();
for (int i = 0; i < coords.Length; ++i)
{
int coord = coords[i];
if (C.SupportsCoordinateSystem(coord))
{
ECCurve c = C;
ECPoint g = G;
bool defaultCoord = (c.CoordinateSystem == coord);
if (!defaultCoord)
{
c = C.Configure().SetCoordinateSystem(coord).Create();
g = c.ImportPoint(G);
}
double avgRate = RandMult(random, g, n);
string coordName = COORD_NAMES[coord];
StringBuilder sb = new StringBuilder();
sb.Append(" ");
sb.Append(defaultCoord ? '*' : ' ');
sb.Append(coordName);
for (int j = sb.Length; j < 30; ++j)
{
sb.Append(' ');
}
sb.Append(": ");
sb.Append(avgRate);
sb.Append(" mults/sec");
for (int j = sb.Length; j < 64; ++j)
{
sb.Append(' ');
}
sb.Append('(');
sb.Append(1000.0 / avgRate);
sb.Append(" millis/mult)");
Console.WriteLine(sb.ToString());
}
}
}
示例3: PerformTest
public override void PerformTest()
{
SecureRandom rand = new SecureRandom(new byte[20]);
rand.SetSeed(DateTime.Now.Ticks);
doTestPadding(new Pkcs7Padding(), rand,
Hex.Decode("ffffff0505050505"),
Hex.Decode("0000000004040404"));
Pkcs7Padding padder = new Pkcs7Padding();
try
{
padder.PadCount(new byte[8]);
Fail("invalid padding not detected");
}
catch (InvalidCipherTextException e)
{
if (!"pad block corrupted".Equals(e.Message))
{
Fail("wrong exception for corrupt padding: " + e);
}
}
doTestPadding(new ISO10126d2Padding(), rand,
null,
null);
doTestPadding(new X923Padding(), rand,
null,
null);
doTestPadding(new TbcPadding(), rand,
Hex.Decode("ffffff0000000000"),
Hex.Decode("00000000ffffffff"));
doTestPadding(new ZeroBytePadding(), rand,
Hex.Decode("ffffff0000000000"),
null);
doTestPadding(new ISO7816d4Padding(), rand,
Hex.Decode("ffffff8000000000"),
Hex.Decode("0000000080000000"));
}
示例4: Test1000
public void Test1000()
{
byte[] testData = new byte[10000];
SecureRandom rand = new SecureRandom();
rand.SetSeed(0);
for (int i = 0; i != 10; i++)
{
CmsCompressedDataStreamGenerator gen = new CmsCompressedDataStreamGenerator();
MemoryStream bOut = new MemoryStream();
Stream cOut = gen.Open(bOut, CmsCompressedDataStreamGenerator.ZLib);
rand.NextBytes(testData);
cOut.Write(testData, 0, testData.Length);
cOut.Close();
CmsCompressedDataParser ed = new CmsCompressedDataParser(bOut.ToArray());
Assert.IsTrue(Arrays.AreEqual(testData, CmsTestUtil.StreamToByteArray(ed.GetContent().ContentStream)));
}
}
示例5: RandomTests
private void RandomTests()
{
SecureRandom srng = new SecureRandom();
srng.SetSeed(DateTimeUtilities.CurrentUnixMs());
for (int i = 0; i < 10; ++i)
{
RandomTest(srng);
}
}
示例6: RandomTests
private void RandomTests()
{
SecureRandom srng = new SecureRandom();
srng.SetSeed(DateTimeUtilities.CurrentUnixMs());
RandomTests(srng, null);
RandomTests(srng, new BasicGcmMultiplier());
RandomTests(srng, new Tables8kGcmMultiplier());
RandomTests(srng, new Tables64kGcmMultiplier());
}