The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_PRIMES_H_INCLUDED
  18. #define JUCE_PRIMES_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. Prime number creation class.
  22. This class contains static methods for generating and testing prime numbers.
  23. @see BigInteger
  24. */
  25. class JUCE_API Primes
  26. {
  27. public:
  28. //==============================================================================
  29. /** Creates a random prime number with a given bit-length.
  30. The certainty parameter specifies how many iterations to use when testing
  31. for primality. A safe value might be anything over about 20-30.
  32. The randomSeeds parameter lets you optionally pass it a set of values with
  33. which to seed the random number generation, improving the security of the
  34. keys generated.
  35. */
  36. static BigInteger createProbablePrime (int bitLength,
  37. int certainty,
  38. const int* randomSeeds = 0,
  39. int numRandomSeeds = 0);
  40. /** Tests a number to see if it's prime.
  41. This isn't a bulletproof test, it uses a Miller-Rabin test to determine
  42. whether the number is prime.
  43. The certainty parameter specifies how many iterations to use when testing - a
  44. safe value might be anything over about 20-30.
  45. */
  46. static bool isProbablyPrime (const BigInteger& number, int certainty);
  47. private:
  48. Primes();
  49. JUCE_DECLARE_NON_COPYABLE (Primes)
  50. };
  51. #endif // JUCE_PRIMES_H_INCLUDED