HashGenerator.php 961 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /*
  3. Hashids
  4. http://hashids.org/php
  5. (c) 2013 Ivan Akimov
  6. https://github.com/ivanakimov/hashids.php
  7. hashids may be freely distributed under the MIT license.
  8. */
  9. namespace Hashids;
  10. /**
  11. * HashGenerator is a contract for generating hashes
  12. */
  13. interface HashGenerator {
  14. /**
  15. * Encodes a variable number of parameters to generate a hash
  16. *
  17. * @param mixed ...
  18. *
  19. * @return string the generated hash
  20. */
  21. public function encode();
  22. /**
  23. * Decodes a hash to the original parameter values
  24. *
  25. * @param string $hash the hash to decode
  26. *
  27. * @return array
  28. */
  29. public function decode($hash);
  30. /**
  31. * Encodes hexadecimal values to generate a hash
  32. *
  33. * @param string $str hexadecimal string
  34. *
  35. * @return string the generated hash
  36. */
  37. public function encode_hex($str);
  38. /**
  39. * Decodes hexadecimal hash
  40. *
  41. * @param string $hash
  42. *
  43. * @return string hexadecimal string
  44. */
  45. public function decode_hex($hash);
  46. }