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