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