本文整理汇总了C#中Mono.Math.BigInteger.isProbablePrime方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.isProbablePrime方法的具体用法?C# BigInteger.isProbablePrime怎么用?C# BigInteger.isProbablePrime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Math.BigInteger
的用法示例。
在下文中一共展示了BigInteger.isProbablePrime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
// initializes the private variables (throws CryptographicException)
private void Initialize(BigInteger p, BigInteger g, BigInteger x, int secretLen, bool checkInput) {
if (!p.isProbablePrime() || g <= 0 || g >= p || (x != null && (x <= 0 || x > p - 2)))
throw new CryptographicException();
// default is to generate a number as large as the prime this
// is usually overkill, but it's the most secure thing we can
// do if the user doesn't specify a desired secret length ...
if (secretLen == 0)
secretLen = p.bitCount();
m_P = p;
m_G = g;
if (x == null) {
BigInteger pm1 = m_P - 1;
for(m_X = BigInteger.genRandom(secretLen); m_X >= pm1 || m_X == 0; m_X = BigInteger.genRandom(secretLen)) {}
} else {
m_X = x;
}
}
示例2: ExpectPrime
private void ExpectPrime (BigInteger bi)
{
Assert.AreEqual (true, bi.isProbablePrime ());
}
示例3: Initialize
private void Initialize(BigInteger p, BigInteger g, BigInteger x)
{
if (!p.isProbablePrime() || g <= 0 || g >= p)
throw new CryptographicException("Inputs p or g are not as expected. P probably isn't a prime or G is less than zero or more than P.");
if(x != null) {
_x = x;
} else {
var pMinus1 = p - 1;
var secretLen = p.bitCount();
for (_x = BigInteger.genRandom(secretLen); _x >= pMinus1 || _x == 0; _x = BigInteger.genRandom(secretLen)) { }
}
_p = p;
_g = g;
}
开发者ID:rackerlabs,项目名称:openstack-guest-agents-windows-xenserver-old,代码行数:16,代码来源:DiffieHellmanManaged.cs
示例4: ExpectComposite
private void ExpectComposite (BigInteger bi)
{
Assert.AreEqual (false, bi.isProbablePrime ());
}