Guest User

Untitled

a guest
Jul 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <?php
  2.  
  3. $tests = array(
  4. 1 => array(
  5. '$5$saltstring',
  6. 'Hello world!',
  7. '$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5'
  8. ),
  9. 2 => array(
  10. '$5$rounds=10000$saltstringsaltstring',
  11. 'Hello world!',
  12. '$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA'
  13. ),
  14. 3 => array(
  15. '$5$rounds=10000$saltstringsaltstring',
  16. 'Hello world!',
  17. '$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA'
  18. ),
  19. 4 => array(
  20. '$5$rounds=5000$toolongsaltstring',
  21. 'This is just a test',
  22. '$5$rounds=5000$toolongsaltstrin$Un/5jzAHMgOGZ5.mWJpuVolil07guHPvOW8mGRcvxa5'
  23. ),
  24. 5 => array(
  25. '$5$rounds=1400$anotherlongsaltstring',
  26. 'a very much longer text to encrypt. This one even stretches over morethan one line.',
  27. '$5$rounds=1400$anotherlongsalts$Rx.j8H.h8HjEDGomFU8bDkXm3XIUnzyxf12oP84Bnq1'
  28. ),
  29. 6 => array(
  30. '$5$rounds=77777$short',
  31. 'we have a short salt string but not a short password',
  32. '$5$rounds=77777$short$JiO1O3ZpDAxGJeaDIuqCoEFysAe1mZNJRs3pw0KQRd/'
  33. ),
  34. 7 => array(
  35. '$5$rounds=123456$asaltof16chars..',
  36. 'a short string',
  37. '$5$rounds=123456$asaltof16chars..$gP3VQ/6X7UUEW3HkBn2w1/Ptq2jxPyzV/cZKmF/wJvD'
  38. ),
  39. 8 => array(
  40. '$5$rounds=10$roundstoolow',
  41. 'the minimum number is still observed',
  42. '$5$rounds=1000$roundstoolow$yfvwcWrQ8l/K0DAWyuPMDNHpIVlTQebY9l/gL972bIC'
  43. )
  44. );
  45.  
  46. foreach ($tests as $iter => $t) {
  47. $res = crypt($t[1], $t[0]);
  48. if ($res != $t[2]) echo "Iteration $iter failed.
  49. Expected: <$t[2]>
  50. Got <$res>\n";
  51. }
  52. echo "Passes.";
Add Comment
Please, Sign In to add comment