crc32.phpt 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. --TEST--
  2. Hash: CRC32 algorithm
  3. --FILE--
  4. <?php
  5. echo "crc32\n";
  6. echo hash('crc32', ''), "\n";
  7. echo hash('crc32', 'a'), "\n";
  8. echo hash('crc32', 'abc'), "\n";
  9. echo hash('crc32', 'message digest'), "\n";
  10. echo hash('crc32', 'abcdefghijklmnopqrstuvwxyz'), "\n";
  11. echo hash('crc32', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), "\n";
  12. echo hash('crc32', '12345678901234567890123456789012345678901234567890123456789012345678901234567890'), "\n";
  13. echo hash('crc32', '1234567890123456'), "\n";
  14. echo hash('crc32', '1234567890123456abc'), "\n";
  15. echo hash('crc32', '12345678901234561234567890123456'), "\n";
  16. echo hash('crc32', '12345678901234561234567890123456abc'), "\n";
  17. echo hash('crc32', '123456789012345612345678901234561234567890123456'), "\n";
  18. echo hash('crc32', '123456789012345612345678901234561234567890123456abc'), "\n";
  19. echo hash('crc32', '1234567890123456123456789012345612345678901234561234567890123456'), "\n";
  20. echo hash('crc32', '1234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
  21. echo hash('crc32', '12345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
  22. echo hash('crc32', '12345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
  23. echo hash('crc32', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
  24. echo hash('crc32', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
  25. echo hash('crc32', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
  26. echo hash('crc32', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
  27. echo "crc32b\n";
  28. echo hash('crc32b', ''), "\n";
  29. echo hash('crc32b', 'a'), "\n";
  30. echo hash('crc32b', 'abc'), "\n";
  31. echo hash('crc32b', 'message digest'), "\n";
  32. echo hash('crc32b', 'abcdefghijklmnopqrstuvwxyz'), "\n";
  33. echo hash('crc32b', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), "\n";
  34. echo hash('crc32b', '12345678901234567890123456789012345678901234567890123456789012345678901234567890'), "\n";
  35. echo hash('crc32b', '1234567890123456'), "\n";
  36. echo hash('crc32b', '1234567890123456abc'), "\n";
  37. echo hash('crc32b', '12345678901234561234567890123456'), "\n";
  38. echo hash('crc32b', '12345678901234561234567890123456abc'), "\n";
  39. echo hash('crc32b', '123456789012345612345678901234561234567890123456'), "\n";
  40. echo hash('crc32b', '123456789012345612345678901234561234567890123456abc'), "\n";
  41. echo hash('crc32b', '1234567890123456123456789012345612345678901234561234567890123456'), "\n";
  42. echo hash('crc32b', '1234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
  43. echo hash('crc32b', '12345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
  44. echo hash('crc32b', '12345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
  45. echo hash('crc32b', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
  46. echo hash('crc32b', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
  47. echo hash('crc32b', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
  48. echo hash('crc32b', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
  49. echo "crc32c\n";
  50. echo hash('crc32c', ''), "\n";
  51. echo hash('crc32c', 'a'), "\n";
  52. echo hash('crc32c', 'ab'), "\n";
  53. echo hash('crc32c', 'abc'), "\n";
  54. echo hash('crc32c', 'abcd'), "\n";
  55. echo hash('crc32c', 'abcde'), "\n";
  56. echo hash('crc32c', 'abcdef'), "\n";
  57. echo hash('crc32c', 'abcdefg'), "\n";
  58. echo hash('crc32c', 'abcdefgh'), "\n";
  59. echo hash('crc32c', 'abcdefghi'), "\n";
  60. echo hash('crc32c', 'abcdefghij'), "\n";
  61. echo hash('crc32c', 'abcdefghijklmnopqrstuvwxyz'), "\n";
  62. echo hash('crc32c', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), "\n";
  63. echo hash('crc32c', '12345678901234567890123456789012345678901234567890123456789012345678901234567890'), "\n";
  64. echo hash('crc32c', 'message digest'), "\n";
  65. echo hash('crc32c', "I can't remember anything"), "\n";
  66. echo hash('crc32c', "I can't remember anything" . "Can’t tell if this is true or dream"), "\n";
  67. echo hash('crc32c', 'Discard medicine more than two years old.'), "\n";
  68. echo hash('crc32c', 'He who has a shady past knows that nice guys finish last.'), "\n";
  69. echo hash('crc32c', "I wouldn't marry him with a ten foot pole."), "\n";
  70. echo hash('crc32c', "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave"), "\n";
  71. echo hash('crc32c', "The days of the digital watch are numbered. -Tom Stoppard"), "\n";
  72. echo hash('crc32c', "Nepal premier won't resign."), "\n";
  73. echo hash('crc32c', "For every action there is an equal and opposite government program."), "\n";
  74. echo hash('crc32c', "His money is twice tainted: 'taint yours and 'taint mine."), "\n";
  75. echo hash('crc32c', "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977"), "\n";
  76. echo hash('crc32c', "It's a tiny change to the code and not completely disgusting. - Bob Manchek"), "\n";
  77. echo hash('crc32c', "size: a.out: bad magic"), "\n";
  78. echo hash('crc32c', "The major problem is with sendmail. -Mark Horton"), "\n";
  79. echo hash('crc32c', "Give me a rock, paper and scissors and I will move the world. CCFestoon"), "\n";
  80. echo hash('crc32c', "If the enemy is within range, then so are you."), "\n";
  81. echo hash('crc32c', "It's well we cannot hear the screams/That we create in others' dreams."), "\n";
  82. echo hash('crc32c', "You remind me of a TV show, but that's all right: I watch it anyway."), "\n";
  83. echo hash('crc32c', "C is as portable as Stonehedge!!"), "\n";
  84. echo hash('crc32c', "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley"), "\n";
  85. echo 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";
  86. echo hash('crc32c', "How can you write a big system without C++? -Paul Glick"), "\n";
  87. echo 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";
  88. echo hash('crc32c', '1234567890123456'), "\n";
  89. echo hash('crc32c', '1234567890123456abc'), "\n";
  90. echo hash('crc32c', '12345678901234561234567890123456'), "\n";
  91. echo hash('crc32c', '12345678901234561234567890123456abc'), "\n";
  92. echo hash('crc32c', '123456789012345612345678901234561234567890123456'), "\n";
  93. echo hash('crc32c', '123456789012345612345678901234561234567890123456abc'), "\n";
  94. echo hash('crc32c', '1234567890123456123456789012345612345678901234561234567890123456'), "\n";
  95. echo hash('crc32c', '1234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
  96. echo hash('crc32c', '12345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
  97. echo hash('crc32c', '12345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
  98. echo hash('crc32c', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
  99. echo hash('crc32c', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
  100. echo hash('crc32c', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
  101. echo hash('crc32c', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
  102. ?>
  103. --EXPECT--
  104. crc32
  105. 00000000
  106. 6b9b9319
  107. 73bb8c64
  108. 5703c9bf
  109. 9693bf77
  110. 882174a0
  111. 96790816
  112. 98b0e78d
  113. a6f33d71
  114. 900a1d38
  115. 396978fe
  116. adfc6afe
  117. d3ef9388
  118. c53911dc
  119. 37006f1b
  120. 4a54af3a
  121. 98d05c71
  122. 5a26f5b4
  123. b9108715
  124. cc684112
  125. b2ac45af
  126. crc32b
  127. 00000000
  128. e8b7be43
  129. 352441c2
  130. 20159d7f
  131. 4c2750bd
  132. 1fc2e6d2
  133. 7ca94a72
  134. 1e5fcdb7
  135. 70b54c2f
  136. 094fb11e
  137. 38210c49
  138. 7399c6ef
  139. 83e98d04
  140. 1f26a94e
  141. e2e8634a
  142. 0642542d
  143. 43b42c9b
  144. 262e1ded
  145. b7a463c4
  146. dfa1bbae
  147. 4022d57a
  148. crc32c
  149. 00000000
  150. c1d04330
  151. e2a22936
  152. 364b3fb7
  153. 92c80a31
  154. c450d697
  155. 53bceff1
  156. e627f441
  157. 0a9421b7
  158. 2ddc99fc
  159. e6599437
  160. 9ee6ef25
  161. a245d57d
  162. 477a6781
  163. 02bd79d0
  164. 5e405e93
  165. 516ad412
  166. b2cc01fe
  167. 0e28207f
  168. be93f964
  169. 9e3be0c3
  170. f505ef04
  171. 85d3dc82
  172. c5142380
  173. 75eb77dd
  174. 91ebe9f7
  175. f0b1168e
  176. 572b74e2
  177. 8a58a6d5
  178. 9c426c50
  179. 735400a4
  180. bec49c95
  181. a95a2079
  182. de2e65c5
  183. 297a88ed
  184. 66ed1d8b
  185. dcded527
  186. 9c44184b
  187. 9aa4287f
  188. ab2761c5
  189. cd486b4b
  190. c19c4a41
  191. 1ea5b441
  192. 36d20512
  193. 31d11ffa
  194. 65d5bb9e
  195. a0e3e317
  196. 8dc10a7c
  197. 7ab04135
  198. c292a38d
  199. e3e558ec
  200. b6c5e13e