md5_basic2.phpt 741 B

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. Test md5() function : basic functionality - with raw output
  3. --FILE--
  4. <?php
  5. /* Prototype : string md5 ( string $str [, bool $raw_output= false ] )
  6. * Description: Calculate the md5 hash of a string
  7. * Source code: ext/standard/md5.c
  8. */
  9. echo "*** Testing md5() : basic functionality - with raw output***\n";
  10. $str = b"Hello World";
  11. $md5_raw = md5($str, true);
  12. var_dump(bin2hex($md5_raw));
  13. $md5 = md5($str, false);
  14. if (strcmp(bin2hex($md5_raw), $md5) == 0 ) {
  15. echo "TEST PASSED\n";
  16. } else {
  17. echo "TEST FAILED\n";
  18. var_dump($md5_raw, $md5);
  19. }
  20. ?>
  21. ===DONE===
  22. --EXPECT--
  23. *** Testing md5() : basic functionality - with raw output***
  24. string(32) "b10a8db164e0754105b7a99be72e3fe5"
  25. TEST PASSED
  26. ===DONE===