crc.cpp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. #include "crc.h"
  2. #include <library/cpp/digest/old_crc/crc.inc>
  3. #include <util/system/defaults.h>
  4. static const ui64 CRCTAB64[256] = {
  5. ULL(0x0000000000000000),
  6. ULL(0xE543279765927881),
  7. ULL(0x2FC568B9AEB68983),
  8. ULL(0xCA864F2ECB24F102),
  9. ULL(0x5F8AD1735D6D1306),
  10. ULL(0xBAC9F6E438FF6B87),
  11. ULL(0x704FB9CAF3DB9A85),
  12. ULL(0x950C9E5D9649E204),
  13. ULL(0xBF15A2E6BADA260C),
  14. ULL(0x5A568571DF485E8D),
  15. ULL(0x90D0CA5F146CAF8F),
  16. ULL(0x7593EDC871FED70E),
  17. ULL(0xE09F7395E7B7350A),
  18. ULL(0x05DC540282254D8B),
  19. ULL(0xCF5A1B2C4901BC89),
  20. ULL(0x2A193CBB2C93C408),
  21. ULL(0x9B68625A10263499),
  22. ULL(0x7E2B45CD75B44C18),
  23. ULL(0xB4AD0AE3BE90BD1A),
  24. ULL(0x51EE2D74DB02C59B),
  25. ULL(0xC4E2B3294D4B279F),
  26. ULL(0x21A194BE28D95F1E),
  27. ULL(0xEB27DB90E3FDAE1C),
  28. ULL(0x0E64FC07866FD69D),
  29. ULL(0x247DC0BCAAFC1295),
  30. ULL(0xC13EE72BCF6E6A14),
  31. ULL(0x0BB8A805044A9B16),
  32. ULL(0xEEFB8F9261D8E397),
  33. ULL(0x7BF711CFF7910193),
  34. ULL(0x9EB4365892037912),
  35. ULL(0x5432797659278810),
  36. ULL(0xB1715EE13CB5F091),
  37. ULL(0xD393E32345DE11B3),
  38. ULL(0x36D0C4B4204C6932),
  39. ULL(0xFC568B9AEB689830),
  40. ULL(0x1915AC0D8EFAE0B1),
  41. ULL(0x8C19325018B302B5),
  42. ULL(0x695A15C77D217A34),
  43. ULL(0xA3DC5AE9B6058B36),
  44. ULL(0x469F7D7ED397F3B7),
  45. ULL(0x6C8641C5FF0437BF),
  46. ULL(0x89C566529A964F3E),
  47. ULL(0x4343297C51B2BE3C),
  48. ULL(0xA6000EEB3420C6BD),
  49. ULL(0x330C90B6A26924B9),
  50. ULL(0xD64FB721C7FB5C38),
  51. ULL(0x1CC9F80F0CDFAD3A),
  52. ULL(0xF98ADF98694DD5BB),
  53. ULL(0x48FB817955F8252A),
  54. ULL(0xADB8A6EE306A5DAB),
  55. ULL(0x673EE9C0FB4EACA9),
  56. ULL(0x827DCE579EDCD428),
  57. ULL(0x1771500A0895362C),
  58. ULL(0xF232779D6D074EAD),
  59. ULL(0x38B438B3A623BFAF),
  60. ULL(0xDDF71F24C3B1C72E),
  61. ULL(0xF7EE239FEF220326),
  62. ULL(0x12AD04088AB07BA7),
  63. ULL(0xD82B4B2641948AA5),
  64. ULL(0x3D686CB12406F224),
  65. ULL(0xA864F2ECB24F1020),
  66. ULL(0x4D27D57BD7DD68A1),
  67. ULL(0x87A19A551CF999A3),
  68. ULL(0x62E2BDC2796BE122),
  69. ULL(0x4264E1D1EE2E5BE7),
  70. ULL(0xA727C6468BBC2366),
  71. ULL(0x6DA189684098D264),
  72. ULL(0x88E2AEFF250AAAE5),
  73. ULL(0x1DEE30A2B34348E1),
  74. ULL(0xF8AD1735D6D13060),
  75. ULL(0x322B581B1DF5C162),
  76. ULL(0xD7687F8C7867B9E3),
  77. ULL(0xFD71433754F47DEB),
  78. ULL(0x183264A03166056A),
  79. ULL(0xD2B42B8EFA42F468),
  80. ULL(0x37F70C199FD08CE9),
  81. ULL(0xA2FB924409996EED),
  82. ULL(0x47B8B5D36C0B166C),
  83. ULL(0x8D3EFAFDA72FE76E),
  84. ULL(0x687DDD6AC2BD9FEF),
  85. ULL(0xD90C838BFE086F7E),
  86. ULL(0x3C4FA41C9B9A17FF),
  87. ULL(0xF6C9EB3250BEE6FD),
  88. ULL(0x138ACCA5352C9E7C),
  89. ULL(0x868652F8A3657C78),
  90. ULL(0x63C5756FC6F704F9),
  91. ULL(0xA9433A410DD3F5FB),
  92. ULL(0x4C001DD668418D7A),
  93. ULL(0x6619216D44D24972),
  94. ULL(0x835A06FA214031F3),
  95. ULL(0x49DC49D4EA64C0F1),
  96. ULL(0xAC9F6E438FF6B870),
  97. ULL(0x3993F01E19BF5A74),
  98. ULL(0xDCD0D7897C2D22F5),
  99. ULL(0x165698A7B709D3F7),
  100. ULL(0xF315BF30D29BAB76),
  101. ULL(0x91F702F2ABF04A54),
  102. ULL(0x74B42565CE6232D5),
  103. ULL(0xBE326A4B0546C3D7),
  104. ULL(0x5B714DDC60D4BB56),
  105. ULL(0xCE7DD381F69D5952),
  106. ULL(0x2B3EF416930F21D3),
  107. ULL(0xE1B8BB38582BD0D1),
  108. ULL(0x04FB9CAF3DB9A850),
  109. ULL(0x2EE2A014112A6C58),
  110. ULL(0xCBA1878374B814D9),
  111. ULL(0x0127C8ADBF9CE5DB),
  112. ULL(0xE464EF3ADA0E9D5A),
  113. ULL(0x716871674C477F5E),
  114. ULL(0x942B56F029D507DF),
  115. ULL(0x5EAD19DEE2F1F6DD),
  116. ULL(0xBBEE3E4987638E5C),
  117. ULL(0x0A9F60A8BBD67ECD),
  118. ULL(0xEFDC473FDE44064C),
  119. ULL(0x255A08111560F74E),
  120. ULL(0xC0192F8670F28FCF),
  121. ULL(0x5515B1DBE6BB6DCB),
  122. ULL(0xB056964C8329154A),
  123. ULL(0x7AD0D962480DE448),
  124. ULL(0x9F93FEF52D9F9CC9),
  125. ULL(0xB58AC24E010C58C1),
  126. ULL(0x50C9E5D9649E2040),
  127. ULL(0x9A4FAAF7AFBAD142),
  128. ULL(0x7F0C8D60CA28A9C3),
  129. ULL(0xEA00133D5C614BC7),
  130. ULL(0x0F4334AA39F33346),
  131. ULL(0xC5C57B84F2D7C244),
  132. ULL(0x20865C139745BAC5),
  133. ULL(0x84C9C3A3DC5CB7CE),
  134. ULL(0x618AE434B9CECF4F),
  135. ULL(0xAB0CAB1A72EA3E4D),
  136. ULL(0x4E4F8C8D177846CC),
  137. ULL(0xDB4312D08131A4C8),
  138. ULL(0x3E003547E4A3DC49),
  139. ULL(0xF4867A692F872D4B),
  140. ULL(0x11C55DFE4A1555CA),
  141. ULL(0x3BDC6145668691C2),
  142. ULL(0xDE9F46D20314E943),
  143. ULL(0x141909FCC8301841),
  144. ULL(0xF15A2E6BADA260C0),
  145. ULL(0x6456B0363BEB82C4),
  146. ULL(0x811597A15E79FA45),
  147. ULL(0x4B93D88F955D0B47),
  148. ULL(0xAED0FF18F0CF73C6),
  149. ULL(0x1FA1A1F9CC7A8357),
  150. ULL(0xFAE2866EA9E8FBD6),
  151. ULL(0x3064C94062CC0AD4),
  152. ULL(0xD527EED7075E7255),
  153. ULL(0x402B708A91179051),
  154. ULL(0xA568571DF485E8D0),
  155. ULL(0x6FEE18333FA119D2),
  156. ULL(0x8AAD3FA45A336153),
  157. ULL(0xA0B4031F76A0A55B),
  158. ULL(0x45F724881332DDDA),
  159. ULL(0x8F716BA6D8162CD8),
  160. ULL(0x6A324C31BD845459),
  161. ULL(0xFF3ED26C2BCDB65D),
  162. ULL(0x1A7DF5FB4E5FCEDC),
  163. ULL(0xD0FBBAD5857B3FDE),
  164. ULL(0x35B89D42E0E9475F),
  165. ULL(0x575A20809982A67D),
  166. ULL(0xB2190717FC10DEFC),
  167. ULL(0x789F483937342FFE),
  168. ULL(0x9DDC6FAE52A6577F),
  169. ULL(0x08D0F1F3C4EFB57B),
  170. ULL(0xED93D664A17DCDFA),
  171. ULL(0x2715994A6A593CF8),
  172. ULL(0xC256BEDD0FCB4479),
  173. ULL(0xE84F826623588071),
  174. ULL(0x0D0CA5F146CAF8F0),
  175. ULL(0xC78AEADF8DEE09F2),
  176. ULL(0x22C9CD48E87C7173),
  177. ULL(0xB7C553157E359377),
  178. ULL(0x528674821BA7EBF6),
  179. ULL(0x98003BACD0831AF4),
  180. ULL(0x7D431C3BB5116275),
  181. ULL(0xCC3242DA89A492E4),
  182. ULL(0x2971654DEC36EA65),
  183. ULL(0xE3F72A6327121B67),
  184. ULL(0x06B40DF4428063E6),
  185. ULL(0x93B893A9D4C981E2),
  186. ULL(0x76FBB43EB15BF963),
  187. ULL(0xBC7DFB107A7F0861),
  188. ULL(0x593EDC871FED70E0),
  189. ULL(0x7327E03C337EB4E8),
  190. ULL(0x9664C7AB56ECCC69),
  191. ULL(0x5CE288859DC83D6B),
  192. ULL(0xB9A1AF12F85A45EA),
  193. ULL(0x2CAD314F6E13A7EE),
  194. ULL(0xC9EE16D80B81DF6F),
  195. ULL(0x036859F6C0A52E6D),
  196. ULL(0xE62B7E61A53756EC),
  197. ULL(0xC6AD22723272EC29),
  198. ULL(0x23EE05E557E094A8),
  199. ULL(0xE9684ACB9CC465AA),
  200. ULL(0x0C2B6D5CF9561D2B),
  201. ULL(0x9927F3016F1FFF2F),
  202. ULL(0x7C64D4960A8D87AE),
  203. ULL(0xB6E29BB8C1A976AC),
  204. ULL(0x53A1BC2FA43B0E2D),
  205. ULL(0x79B8809488A8CA25),
  206. ULL(0x9CFBA703ED3AB2A4),
  207. ULL(0x567DE82D261E43A6),
  208. ULL(0xB33ECFBA438C3B27),
  209. ULL(0x263251E7D5C5D923),
  210. ULL(0xC3717670B057A1A2),
  211. ULL(0x09F7395E7B7350A0),
  212. ULL(0xECB41EC91EE12821),
  213. ULL(0x5DC540282254D8B0),
  214. ULL(0xB88667BF47C6A031),
  215. ULL(0x720028918CE25133),
  216. ULL(0x97430F06E97029B2),
  217. ULL(0x024F915B7F39CBB6),
  218. ULL(0xE70CB6CC1AABB337),
  219. ULL(0x2D8AF9E2D18F4235),
  220. ULL(0xC8C9DE75B41D3AB4),
  221. ULL(0xE2D0E2CE988EFEBC),
  222. ULL(0x0793C559FD1C863D),
  223. ULL(0xCD158A773638773F),
  224. ULL(0x2856ADE053AA0FBE),
  225. ULL(0xBD5A33BDC5E3EDBA),
  226. ULL(0x5819142AA071953B),
  227. ULL(0x929F5B046B556439),
  228. ULL(0x77DC7C930EC71CB8),
  229. ULL(0x153EC15177ACFD9A),
  230. ULL(0xF07DE6C6123E851B),
  231. ULL(0x3AFBA9E8D91A7419),
  232. ULL(0xDFB88E7FBC880C98),
  233. ULL(0x4AB410222AC1EE9C),
  234. ULL(0xAFF737B54F53961D),
  235. ULL(0x6571789B8477671F),
  236. ULL(0x80325F0CE1E51F9E),
  237. ULL(0xAA2B63B7CD76DB96),
  238. ULL(0x4F684420A8E4A317),
  239. ULL(0x85EE0B0E63C05215),
  240. ULL(0x60AD2C9906522A94),
  241. ULL(0xF5A1B2C4901BC890),
  242. ULL(0x10E29553F589B011),
  243. ULL(0xDA64DA7D3EAD4113),
  244. ULL(0x3F27FDEA5B3F3992),
  245. ULL(0x8E56A30B678AC903),
  246. ULL(0x6B15849C0218B182),
  247. ULL(0xA193CBB2C93C4080),
  248. ULL(0x44D0EC25ACAE3801),
  249. ULL(0xD1DC72783AE7DA05),
  250. ULL(0x349F55EF5F75A284),
  251. ULL(0xFE191AC194515386),
  252. ULL(0x1B5A3D56F1C32B07),
  253. ULL(0x314301EDDD50EF0F),
  254. ULL(0xD400267AB8C2978E),
  255. ULL(0x1E86695473E6668C),
  256. ULL(0xFBC54EC316741E0D),
  257. ULL(0x6EC9D09E803DFC09),
  258. ULL(0x8B8AF709E5AF8488),
  259. ULL(0x410CB8272E8B758A),
  260. ULL(0xA44F9FB04B190D0B),
  261. };
  262. const ui32* crctab16 = CRCTAB16;
  263. const ui32* crctab32 = CRCTAB32;
  264. const ui64* crctab64 = CRCTAB64;