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.

75 lines
2.7KB

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