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		b'$5$saltstring',
15		b'Hello world!',
16		b'$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5'
17	),
18	2 => array(
19		b'$5$rounds=10000$saltstringsaltstring',
20		b'Hello world!',
21		b'$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA'
22	),
23	3 => array(
24		b'$5$rounds=10000$saltstringsaltstring',
25		b'Hello world!',
26		b'$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA'
27	),
28	4 => array(
29		b'$5$rounds=5000$toolongsaltstring',
30		b'This is just a test',
31		b'$5$rounds=5000$toolongsaltstrin$Un/5jzAHMgOGZ5.mWJpuVolil07guHPvOW8mGRcvxa5'
32	),
33	5 => array(
34		b'$5$rounds=1400$anotherlongsaltstring',
35		b'a very much longer text to encrypt.  This one even stretches over morethan one line.',
36		b'$5$rounds=1400$anotherlongsalts$Rx.j8H.h8HjEDGomFU8bDkXm3XIUnzyxf12oP84Bnq1'
37	),
38	6 => array(
39		b'$5$rounds=77777$short',
40		b'we have a short salt string but not a short password',
41		b'$5$rounds=77777$short$JiO1O3ZpDAxGJeaDIuqCoEFysAe1mZNJRs3pw0KQRd/'
42	),
43	7 => array(
44		b'$5$rounds=123456$asaltof16chars..',
45		b'a short string',
46		b'$5$rounds=123456$asaltof16chars..$gP3VQ/6X7UUEW3HkBn2w1/Ptq2jxPyzV/cZKmF/wJvD'
47	),
48	8 => array(
49		b'$5$rounds=10$roundstoolow',
50		b'the minimum number is still observed',
51		b'$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