crypt_sha512.phpt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. --TEST--
  2. crypt() SHA-512
  3. --FILE--
  4. <?php
  5. $tests = array(
  6. 1 => array(
  7. '$6$saltstring',
  8. 'Hello world!',
  9. '$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJuesI68u4OTLiBFdcbYEdFCoEOfaS35inz1'
  10. ),
  11. 2 => array(
  12. '$6$rounds=10000$saltstringsaltstring',
  13. 'Hello world!',
  14. '$6$rounds=10000$saltstringsaltst$OW1/O6BYHV6BcXZu8QVeXbDWra3Oeqh0sbHbbMCVNSnCM/UrjmM0Dp8vOuZeHBy/YTBmSK6H9qs/y3RnOaw5v.'
  15. ),
  16. 3 => array(
  17. '$6$rounds=5000$toolongsaltstring',
  18. 'This is just a test',
  19. '$6$rounds=5000$toolongsaltstrin$lQ8jolhgVRVhY4b5pZKaysCLi0QBxGoNeKQzQ3glMhwllF7oGDZxUhx1yxdYcz/e1JSbq3y6JMxxl8audkUEm0'
  20. ),
  21. 4 => array(
  22. '$6$rounds=1400$anotherlongsaltstring',
  23. 'a very much longer text to encrypt. This one even stretches over morethan one line.',
  24. '$6$rounds=1400$anotherlongsalts$POfYwTEok97VWcjxIiSOjiykti.o/pQs.wPvMxQ6Fm7I6IoYN3CmLs66x9t0oSwbtEW7o7UmJEiDwGqd8p4ur1'
  25. ),
  26. 5 => array(
  27. '$6$rounds=77777$short',
  28. 'we have a short salt string but not a short password',
  29. '$6$rounds=77777$short$WuQyW2YR.hBNpjjRhpYD/ifIw05xdfeEyQoMxIXbkvr0gge1a1x3yRULJ5CCaUeOxFmtlcGZelFl5CxtgfiAc0'
  30. ),
  31. 6 => array(
  32. '$6$rounds=123456$asaltof16chars..',
  33. 'a short string',
  34. '$6$rounds=123456$asaltof16chars..$BtCwjqMJGx5hrJhZywWvt0RLE8uZ4oPwcelCjmw2kSYu.Ec6ycULevoBK25fs2xXgMNrCzIMVcgEJAstJeonj1'
  35. ),
  36. 7 => array(
  37. '$6$$bar$',
  38. 'foo',
  39. '$6$$QMXjqd7rHQZPQ1yHsXkQqC1FBzDiVfTHXL.LaeDAeVV.IzMaV9VU4MQ8kPuZa2SOP1A0RPm772EaFYjpEJtdu.'
  40. ),
  41. 8 => array(
  42. '$6$rounds=10$roundstoolow',
  43. 'the number of rounds is too low',
  44. '*0'
  45. ),
  46. 8 => array(
  47. '$6$rounds=1000000000$roundstoohigh',
  48. 'the number of rounds is too high',
  49. '*0'
  50. ),
  51. );
  52. foreach ($tests as $iter => $t) {
  53. $res = crypt($t[1], $t[0]);
  54. if ($res != $t[2]) echo "Iteration $iter failed.
  55. Expected: <$t[2]>
  56. Got <$res>\n";
  57. }
  58. echo "Passes.";
  59. ?>
  60. --EXPECT--
  61. Passes.