Mono.Math.BigInteger.isProbablePrime C# (CSharp) Méthode

isProbablePrime() public méthode

public isProbablePrime ( ) : bool
Résultat bool
		public bool isProbablePrime ()
		{

			for (int p = 0; p < smallPrimes.Length; p++) {
				if (this == smallPrimes [p])
					return true;
				if (this % smallPrimes [p] == 0)
					return false;
			}

			return PrimalityTests.RabinMillerTest (this, Prime.ConfidenceFactor.Medium);
		}

Same methods

BigInteger::isProbablePrime ( int notUsed ) : bool

Usage Example

		// 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;
			}
		}
All Usage Examples Of Mono.Math.BigInteger::isProbablePrime