1--TEST-- 2crypt() SHA-256 3--FILE-- 4<?php 5 6$tests = array( 7 1 => array( 8 '$5$saltstring', 9 'Hello world!', 10 '$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5' 11 ), 12 2 => array( 13 '$5$rounds=10000$saltstringsaltstring', 14 'Hello world!', 15 '$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA' 16 ), 17 3 => array( 18 '$5$rounds=10000$saltstringsaltstring', 19 'Hello world!', 20 '$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA' 21 ), 22 4 => array( 23 '$5$rounds=5000$toolongsaltstring', 24 'This is just a test', 25 '$5$rounds=5000$toolongsaltstrin$Un/5jzAHMgOGZ5.mWJpuVolil07guHPvOW8mGRcvxa5' 26 ), 27 5 => array( 28 '$5$rounds=1400$anotherlongsaltstring', 29 'a very much longer text to encrypt. This one even stretches over morethan one line.', 30 '$5$rounds=1400$anotherlongsalts$Rx.j8H.h8HjEDGomFU8bDkXm3XIUnzyxf12oP84Bnq1' 31 ), 32 6 => array( 33 '$5$rounds=77777$short', 34 'we have a short salt string but not a short password', 35 '$5$rounds=77777$short$JiO1O3ZpDAxGJeaDIuqCoEFysAe1mZNJRs3pw0KQRd/' 36 ), 37 7 => array( 38 '$5$rounds=123456$asaltof16chars..', 39 'a short string', 40 '$5$rounds=123456$asaltof16chars..$gP3VQ/6X7UUEW3HkBn2w1/Ptq2jxPyzV/cZKmF/wJvD' 41 ), 42 43 // The "too many rounds" behavior depends on the crypt() 44 // implementation, but for now everyone agrees on what to do. 45 8 => array( 46 '$5$rounds=1000000000$roundstoohigh', 47 'the number of rounds is too high', 48 '*0' 49 ) 50); 51 52foreach ($tests as $iter => $t) { 53 $res = crypt($t[1], $t[0]); 54 if ($res != $t[2]) echo "Iteration $iter failed. 55Expected: <$t[2]> 56Got <$res>\n"; 57} 58echo "Passes.";?> 59--EXPECT-- 60Passes. 61