summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/crypt_sha512.phpt
blob: d6f9df6013985ee8edcb07da992105fd0f5ef8bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
--TEST--
crypt() SHA-512
--SKIPIF--
<?php
if (!function_exists('crypt') || !defined("CRYPT_SHA512")) {
	die("SKIP crypt()-sha512 is not available");
}
?> 
--FILE--
<?php

$tests = array(
	1 => array(
		b'$6$saltstring',
		b'Hello world!',
		b'$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJuesI68u4OTLiBFdcbYEdFCoEOfaS35inz1'
	),
	2 => array(
		b'$6$rounds=10000$saltstringsaltstring',
		b'Hello world!',
		b'$6$rounds=10000$saltstringsaltst$OW1/O6BYHV6BcXZu8QVeXbDWra3Oeqh0sbHbbMCVNSnCM/UrjmM0Dp8vOuZeHBy/YTBmSK6H9qs/y3RnOaw5v.'
	),
	3 => array(
		b'$6$rounds=5000$toolongsaltstring',
		b'This is just a test',
		b'$6$rounds=5000$toolongsaltstrin$lQ8jolhgVRVhY4b5pZKaysCLi0QBxGoNeKQzQ3glMhwllF7oGDZxUhx1yxdYcz/e1JSbq3y6JMxxl8audkUEm0'
	),
	4 => array(
		b'$6$rounds=1400$anotherlongsaltstring',
		b'a very much longer text to encrypt.  This one even stretches over morethan one line.',
		b'$6$rounds=1400$anotherlongsalts$POfYwTEok97VWcjxIiSOjiykti.o/pQs.wPvMxQ6Fm7I6IoYN3CmLs66x9t0oSwbtEW7o7UmJEiDwGqd8p4ur1'
	),
	5 => array(
		b'$6$rounds=77777$short',
		b'we have a short salt string but not a short password',
		b'$6$rounds=77777$short$WuQyW2YR.hBNpjjRhpYD/ifIw05xdfeEyQoMxIXbkvr0gge1a1x3yRULJ5CCaUeOxFmtlcGZelFl5CxtgfiAc0'
	),
	6 => array(
		b'$6$rounds=123456$asaltof16chars..',
		b'a short string',
		b'$6$rounds=123456$asaltof16chars..$BtCwjqMJGx5hrJhZywWvt0RLE8uZ4oPwcelCjmw2kSYu.Ec6ycULevoBK25fs2xXgMNrCzIMVcgEJAstJeonj1'
	),
	7 => array(
		b'$6$rounds=10$roundstoolow',
		b'the minimum number is still observed',
		b'$6$rounds=1000$roundstoolow$kUMsbe306n21p9R.FRkW3IGn.S9NPN0x50YhH1xhLsPuWGsUSklZt58jaTfF4ZEQpyUNGc0dqbpBYYBaHHrsX.'
	),
	8 => array(
		b'$6$$bar$',
		b'foo',
		b'$6$$QMXjqd7rHQZPQ1yHsXkQqC1FBzDiVfTHXL.LaeDAeVV.IzMaV9VU4MQ8kPuZa2SOP1A0RPm772EaFYjpEJtdu.'
	),
);

foreach ($tests as $iter => $t) {
	$res = crypt($t[1], $t[0]);
	if ($res != $t[2]) echo "Iteration $iter failed.
Expected: <$t[2]>
Got       <$res>\n";
}
echo "Passes.";
?>
--EXPECTF--
Passes.