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