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.

70 lines
2.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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. #pragma once
  18. //==============================================================================
  19. /**
  20. Prime number creation class.
  21. This class contains static methods for generating and testing prime numbers.
  22. @see BigInteger
  23. */
  24. class JUCE_API Primes
  25. {
  26. public:
  27. //==============================================================================
  28. /** Creates a random prime number with a given bit-length.
  29. The certainty parameter specifies how many iterations to use when testing
  30. for primality. A safe value might be anything over about 20-30.
  31. The randomSeeds parameter lets you optionally pass it a set of values with
  32. which to seed the random number generation, improving the security of the
  33. keys generated.
  34. */
  35. static BigInteger createProbablePrime (int bitLength,
  36. int certainty,
  37. const int* randomSeeds = 0,
  38. int numRandomSeeds = 0);
  39. /** Tests a number to see if it's prime.
  40. This isn't a bulletproof test, it uses a Miller-Rabin test to determine
  41. whether the number is prime.
  42. The certainty parameter specifies how many iterations to use when testing - a
  43. safe value might be anything over about 20-30.
  44. */
  45. static bool isProbablyPrime (const BigInteger& number, int certainty);
  46. private:
  47. Primes();
  48. JUCE_DECLARE_NON_COPYABLE (Primes)
  49. };