Source.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /*
  3. * The RandomLib library for securely generating random numbers and strings in PHP
  4. *
  5. * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
  6. * @copyright 2011 The Authors
  7. * @license http://www.opensource.org/licenses/mit-license.html MIT License
  8. * @version Build @@version@@
  9. */
  10. /**
  11. * The Random Number Source interface.
  12. *
  13. * All random number sources must implement this interface
  14. *
  15. * PHP version 5.3
  16. *
  17. * @category PHPPasswordLib
  18. * @package Random
  19. *
  20. * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
  21. * @copyright 2011 The Authors
  22. * @license http://www.opensource.org/licenses/mit-license.html MIT License
  23. *
  24. * @version Build @@version@@
  25. */
  26. namespace RandomLib;
  27. /**
  28. * The Random Number Source interface.
  29. *
  30. * All random number sources must implement this interface
  31. *
  32. * @category PHPPasswordLib
  33. * @package Random
  34. *
  35. * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
  36. * @codeCoverageIgnore
  37. */
  38. interface Source
  39. {
  40. /**
  41. * Return an instance of Strength indicating the strength of the source
  42. *
  43. * @return \SecurityLib\Strength An instance of one of the strength classes
  44. */
  45. public static function getStrength();
  46. /**
  47. * If the source is currently available.
  48. * Reasons might be because the library is not installed
  49. *
  50. * @return bool
  51. */
  52. public static function isSupported();
  53. /**
  54. * Generate a random string of the specified size
  55. *
  56. * Note: If the source fails to generate enough data, the result must be
  57. * padded to the requested length.
  58. *
  59. * @param int $size The size of the requested random string
  60. *
  61. * @return string A string of the requested size
  62. */
  63. public function generate($size);
  64. }