xref: /php-src/ext/hash/tests/crc32.phpt (revision c3299d7d)
1--TEST--
2Hash: CRC32 algorithm
3--FILE--
4<?php
5echo "crc32\n";
6echo hash('crc32', ''), "\n";
7echo hash('crc32', 'a'), "\n";
8echo hash('crc32', 'abc'), "\n";
9echo hash('crc32', 'message digest'), "\n";
10echo hash('crc32', 'abcdefghijklmnopqrstuvwxyz'), "\n";
11echo hash('crc32', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), "\n";
12echo hash('crc32', '12345678901234567890123456789012345678901234567890123456789012345678901234567890'), "\n";
13echo hash('crc32', '1234567890123456'), "\n";
14echo hash('crc32', '1234567890123456abc'), "\n";
15echo hash('crc32', '12345678901234561234567890123456'), "\n";
16echo hash('crc32', '12345678901234561234567890123456abc'), "\n";
17echo hash('crc32', '123456789012345612345678901234561234567890123456'), "\n";
18echo hash('crc32', '123456789012345612345678901234561234567890123456abc'), "\n";
19echo hash('crc32', '1234567890123456123456789012345612345678901234561234567890123456'), "\n";
20echo hash('crc32', '1234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
21echo hash('crc32', '12345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
22echo hash('crc32', '12345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
23echo hash('crc32', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
24echo hash('crc32', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
25echo hash('crc32', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
26echo hash('crc32', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
27
28echo "crc32b\n";
29echo hash('crc32b', ''), "\n";
30echo hash('crc32b', 'a'), "\n";
31echo hash('crc32b', 'abc'), "\n";
32echo hash('crc32b', 'message digest'), "\n";
33echo hash('crc32b', 'abcdefghijklmnopqrstuvwxyz'), "\n";
34echo hash('crc32b', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), "\n";
35echo hash('crc32b', '12345678901234567890123456789012345678901234567890123456789012345678901234567890'), "\n";
36echo hash('crc32b', '1234567890123456'), "\n";
37echo hash('crc32b', '1234567890123456abc'), "\n";
38echo hash('crc32b', '12345678901234561234567890123456'), "\n";
39echo hash('crc32b', '12345678901234561234567890123456abc'), "\n";
40echo hash('crc32b', '123456789012345612345678901234561234567890123456'), "\n";
41echo hash('crc32b', '123456789012345612345678901234561234567890123456abc'), "\n";
42echo hash('crc32b', '1234567890123456123456789012345612345678901234561234567890123456'), "\n";
43echo hash('crc32b', '1234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
44echo hash('crc32b', '12345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
45echo hash('crc32b', '12345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
46echo hash('crc32b', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
47echo hash('crc32b', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
48echo hash('crc32b', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
49echo hash('crc32b', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
50
51echo "crc32c\n";
52echo hash('crc32c', ''), "\n";
53echo hash('crc32c', 'a'), "\n";
54echo hash('crc32c', 'ab'), "\n";
55echo hash('crc32c', 'abc'), "\n";
56echo hash('crc32c', 'abcd'), "\n";
57echo hash('crc32c', 'abcde'), "\n";
58echo hash('crc32c', 'abcdef'), "\n";
59echo hash('crc32c', 'abcdefg'), "\n";
60echo hash('crc32c', 'abcdefgh'), "\n";
61echo hash('crc32c', 'abcdefghi'), "\n";
62echo hash('crc32c', 'abcdefghij'), "\n";
63echo hash('crc32c', 'abcdefghijklmnopqrstuvwxyz'), "\n";
64echo hash('crc32c', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), "\n";
65echo hash('crc32c', '12345678901234567890123456789012345678901234567890123456789012345678901234567890'), "\n";
66echo hash('crc32c', 'message digest'), "\n";
67echo hash('crc32c', "I can't remember anything"), "\n";
68echo hash('crc32c', "I can't remember anything" . "Can’t tell if this is true or dream"), "\n";
69echo hash('crc32c', 'Discard medicine more than two years old.'), "\n";
70echo hash('crc32c', 'He who has a shady past knows that nice guys finish last.'), "\n";
71echo hash('crc32c', "I wouldn't marry him with a ten foot pole."), "\n";
72echo hash('crc32c', "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave"), "\n";
73echo hash('crc32c', "The days of the digital watch are numbered.  -Tom Stoppard"), "\n";
74echo hash('crc32c', "Nepal premier won't resign."), "\n";
75echo hash('crc32c', "For every action there is an equal and opposite government program."), "\n";
76echo hash('crc32c', "His money is twice tainted: 'taint yours and 'taint mine."), "\n";
77echo hash('crc32c', "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977"), "\n";
78echo hash('crc32c', "It's a tiny change to the code and not completely disgusting. - Bob Manchek"), "\n";
79echo hash('crc32c', "size:  a.out:  bad magic"), "\n";
80echo hash('crc32c', "The major problem is with sendmail.  -Mark Horton"), "\n";
81echo hash('crc32c', "Give me a rock, paper and scissors and I will move the world.  CCFestoon"), "\n";
82echo hash('crc32c', "If the enemy is within range, then so are you."), "\n";
83echo hash('crc32c', "It's well we cannot hear the screams/That we create in others' dreams."), "\n";
84echo hash('crc32c', "You remind me of a TV show, but that's all right: I watch it anyway."), "\n";
85echo hash('crc32c', "C is as portable as Stonehedge!!"), "\n";
86echo hash('crc32c', "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley"), "\n";
87echo hash('crc32c', "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction.  Lewis-Randall Rule"), "\n";
88echo hash('crc32c', "How can you write a big system without C++?  -Paul Glick"), "\n";
89echo hash('crc32c', "\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#\$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"), "\n";
90echo hash('crc32c', '1234567890123456'), "\n";
91echo hash('crc32c', '1234567890123456abc'), "\n";
92echo hash('crc32c', '12345678901234561234567890123456'), "\n";
93echo hash('crc32c', '12345678901234561234567890123456abc'), "\n";
94echo hash('crc32c', '123456789012345612345678901234561234567890123456'), "\n";
95echo hash('crc32c', '123456789012345612345678901234561234567890123456abc'), "\n";
96echo hash('crc32c', '1234567890123456123456789012345612345678901234561234567890123456'), "\n";
97echo hash('crc32c', '1234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
98echo hash('crc32c', '12345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
99echo hash('crc32c', '12345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
100echo hash('crc32c', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
101echo hash('crc32c', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
102echo hash('crc32c', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
103echo hash('crc32c', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
104
105?>
106--EXPECT--
107crc32
10800000000
1096b9b9319
11073bb8c64
1115703c9bf
1129693bf77
113882174a0
11496790816
11598b0e78d
116a6f33d71
117900a1d38
118396978fe
119adfc6afe
120d3ef9388
121c53911dc
12237006f1b
1234a54af3a
12498d05c71
1255a26f5b4
126b9108715
127cc684112
128b2ac45af
129crc32b
13000000000
131e8b7be43
132352441c2
13320159d7f
1344c2750bd
1351fc2e6d2
1367ca94a72
1371e5fcdb7
13870b54c2f
139094fb11e
14038210c49
1417399c6ef
14283e98d04
1431f26a94e
144e2e8634a
1450642542d
14643b42c9b
147262e1ded
148b7a463c4
149dfa1bbae
1504022d57a
151crc32c
15200000000
153c1d04330
154e2a22936
155364b3fb7
15692c80a31
157c450d697
15853bceff1
159e627f441
1600a9421b7
1612ddc99fc
162e6599437
1639ee6ef25
164a245d57d
165477a6781
16602bd79d0
1675e405e93
168516ad412
169b2cc01fe
1700e28207f
171be93f964
1729e3be0c3
173f505ef04
17485d3dc82
175c5142380
17675eb77dd
17791ebe9f7
178f0b1168e
179572b74e2
1808a58a6d5
1819c426c50
182735400a4
183bec49c95
184a95a2079
185de2e65c5
186297a88ed
18766ed1d8b
188dcded527
1899c44184b
1909aa4287f
191ab2761c5
192cd486b4b
193c19c4a41
1941ea5b441
19536d20512
19631d11ffa
19765d5bb9e
198a0e3e317
1998dc10a7c
2007ab04135
201c292a38d
202e3e558ec
203b6c5e13e
204