xref: /PHP-7.4/ext/hash/tests/crc32.phpt (revision c79ce48d)
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";
13
14echo "crc32b\n";
15echo hash('crc32b', ''), "\n";
16echo hash('crc32b', 'a'), "\n";
17echo hash('crc32b', 'abc'), "\n";
18echo hash('crc32b', 'message digest'), "\n";
19echo hash('crc32b', 'abcdefghijklmnopqrstuvwxyz'), "\n";
20echo hash('crc32b', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), "\n";
21echo hash('crc32b', '12345678901234567890123456789012345678901234567890123456789012345678901234567890'), "\n";
22
23echo "crc32c\n";
24echo hash('crc32c', ''), "\n";
25echo hash('crc32c', 'a'), "\n";
26echo hash('crc32c', 'ab'), "\n";
27echo hash('crc32c', 'abc'), "\n";
28echo hash('crc32c', 'abcd'), "\n";
29echo hash('crc32c', 'abcde'), "\n";
30echo hash('crc32c', 'abcdef'), "\n";
31echo hash('crc32c', 'abcdefg'), "\n";
32echo hash('crc32c', 'abcdefgh'), "\n";
33echo hash('crc32c', 'abcdefghi'), "\n";
34echo hash('crc32c', 'abcdefghij'), "\n";
35echo hash('crc32c', 'abcdefghijklmnopqrstuvwxyz'), "\n";
36echo hash('crc32c', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), "\n";
37echo hash('crc32c', '12345678901234567890123456789012345678901234567890123456789012345678901234567890'), "\n";
38echo hash('crc32c', 'message digest'), "\n";
39echo hash('crc32c', "I can't remember anything"), "\n";
40echo hash('crc32c', "I can't remember anything" . "Can’t tell if this is true or dream"), "\n";
41echo hash('crc32c', 'Discard medicine more than two years old.'), "\n";
42echo hash('crc32c', 'He who has a shady past knows that nice guys finish last.'), "\n";
43echo hash('crc32c', "I wouldn't marry him with a ten foot pole."), "\n";
44echo hash('crc32c', "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave"), "\n";
45echo hash('crc32c', "The days of the digital watch are numbered.  -Tom Stoppard"), "\n";
46echo hash('crc32c', "Nepal premier won't resign."), "\n";
47echo hash('crc32c', "For every action there is an equal and opposite government program."), "\n";
48echo hash('crc32c', "His money is twice tainted: 'taint yours and 'taint mine."), "\n";
49echo hash('crc32c', "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977"), "\n";
50echo hash('crc32c', "It's a tiny change to the code and not completely disgusting. - Bob Manchek"), "\n";
51echo hash('crc32c', "size:  a.out:  bad magic"), "\n";
52echo hash('crc32c', "The major problem is with sendmail.  -Mark Horton"), "\n";
53echo hash('crc32c', "Give me a rock, paper and scissors and I will move the world.  CCFestoon"), "\n";
54echo hash('crc32c', "If the enemy is within range, then so are you."), "\n";
55echo hash('crc32c', "It's well we cannot hear the screams/That we create in others' dreams."), "\n";
56echo hash('crc32c', "You remind me of a TV show, but that's all right: I watch it anyway."), "\n";
57echo hash('crc32c', "C is as portable as Stonehedge!!"), "\n";
58echo hash('crc32c', "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley"), "\n";
59echo 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";
60echo hash('crc32c', "How can you write a big system without C++?  -Paul Glick"), "\n";
61echo 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";
62
63?>
64--EXPECT--
65crc32
6600000000
676b9b9319
6873bb8c64
695703c9bf
709693bf77
71882174a0
7296790816
73crc32b
7400000000
75e8b7be43
76352441c2
7720159d7f
784c2750bd
791fc2e6d2
807ca94a72
81crc32c
8200000000
83c1d04330
84e2a22936
85364b3fb7
8692c80a31
87c450d697
8853bceff1
89e627f441
900a9421b7
912ddc99fc
92e6599437
939ee6ef25
94a245d57d
95477a6781
9602bd79d0
975e405e93
98516ad412
99b2cc01fe
1000e28207f
101be93f964
1029e3be0c3
103f505ef04
10485d3dc82
105c5142380
10675eb77dd
10791ebe9f7
108f0b1168e
109572b74e2
1108a58a6d5
1119c426c50
112735400a4
113bec49c95
114a95a2079
115de2e65c5
116297a88ed
11766ed1d8b
118dcded527
1199c44184b