PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/core/src/main/php/util/collections/MD5HexHashImplementation.class.php

http://github.com/xp-framework/xp-framework
PHP | 38 lines | 8 code | 3 blank | 27 comment | 0 complexity | dafdfe5af147660b4e93e17bb11bffb7 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /* This class is part of the XP framework
  3. *
  4. * $Id$
  5. */
  6. uses('util.collections.HashImplementation');
  7. /**
  8. * MD5 implementation that uses hexdec() on md5() to calculate the
  9. * numeric value instead of relying on addition taking care of this.
  10. *
  11. * Bug this works around:
  12. * <pre>
  13. * $ php -r '$o= 0; $o+= "0x12195d4e54299a3cc1bde564c5de04b6"; var_dump($o);'
  14. *
  15. * // 5.2.0 : int(0)
  16. * // 5.2.10: float(2.4057803815529E+37)
  17. * </pre>
  18. *
  19. * @see php://md5
  20. * @see php://hexdec
  21. * @see xp://util.collections.HashProvider
  22. * @test xp://net.xp_framework.unittest.util.collections.MD5HexHashImplementationTest:
  23. */
  24. class MD5HexHashImplementation extends Object implements HashImplementation {
  25. /**
  26. * Retrieve hash code for a given string
  27. *
  28. * @param string str
  29. * @return int hashcode
  30. */
  31. public function hashOf($str) {
  32. return hexdec(md5($str));
  33. }
  34. }
  35. ?>