digest-crc 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/integration.yml +1 -1
  3. data/.github/workflows/ruby.yml +6 -6
  4. data/ChangeLog.md +11 -0
  5. data/Gemfile +2 -1
  6. data/LICENSE.txt +1 -1
  7. data/README.md +5 -10
  8. data/benchmarks.rb +1 -0
  9. data/digest-crc.gemspec +8 -4
  10. data/ext/digest/crc12_3gpp/crc12_3gpp_ext.c +4 -0
  11. data/ext/digest/crc15/crc15_ext.c +4 -0
  12. data/ext/digest/crc16/crc16_ext.c +4 -0
  13. data/ext/digest/crc16_ccitt/crc16_ccitt_ext.c +4 -0
  14. data/ext/digest/crc16_dnp/crc16_dnp_ext.c +4 -0
  15. data/ext/digest/crc16_genibus/crc16_genibus_ext.c +4 -0
  16. data/ext/digest/crc16_kermit/crc16_kermit_ext.c +4 -0
  17. data/ext/digest/crc16_modbus/crc16_modbus_ext.c +4 -1
  18. data/ext/digest/crc16_usb/crc16_usb_ext.c +4 -1
  19. data/ext/digest/crc16_x_25/crc16_x_25_ext.c +4 -1
  20. data/ext/digest/crc16_xmodem/crc16_xmodem_ext.c +4 -0
  21. data/ext/digest/crc16_zmodem/crc16_zmodem_ext.c +4 -0
  22. data/ext/digest/crc24/crc24_ext.c +4 -0
  23. data/ext/digest/crc32/crc32_ext.c +4 -0
  24. data/ext/digest/crc32_bzip2/crc32_bzip2_ext.c +4 -0
  25. data/ext/digest/crc32_jam/crc32_jam_ext.c +4 -1
  26. data/ext/digest/crc32_mpeg/crc32_mpeg_ext.c +4 -0
  27. data/ext/digest/crc32_posix/crc32_posix_ext.c +4 -0
  28. data/ext/digest/crc32_xfer/crc32_xfer_ext.c +4 -0
  29. data/ext/digest/crc32c/crc32c_ext.c +4 -1
  30. data/ext/digest/crc5/crc5_ext.c +4 -0
  31. data/ext/digest/crc64/crc64_ext.c +4 -0
  32. data/ext/digest/crc64_jones/crc64_jones_ext.c +4 -1
  33. data/ext/digest/crc64_nvme/crc64_nvme.c +102 -0
  34. data/ext/digest/crc64_nvme/crc64_nvme.h +8 -0
  35. data/ext/digest/crc64_nvme/crc64_nvme_ext.c +31 -0
  36. data/ext/digest/crc64_nvme/extconf.rb +7 -0
  37. data/ext/digest/crc64_xz/crc64_xz_ext.c +4 -1
  38. data/ext/digest/crc8/crc8_ext.c +4 -0
  39. data/ext/digest/crc8_1wire/crc8_1wire_ext.c +4 -1
  40. data/gemspec.yml +1 -1
  41. data/lib/digest/crc.rb +85 -9
  42. data/lib/digest/crc1.rb +2 -0
  43. data/lib/digest/crc15.rb +2 -32
  44. data/lib/digest/crc16.rb +2 -32
  45. data/lib/digest/crc16_ccitt.rb +2 -14
  46. data/lib/digest/crc16_dnp.rb +2 -14
  47. data/lib/digest/crc16_genibus.rb +2 -14
  48. data/lib/digest/crc16_kermit.rb +2 -14
  49. data/lib/digest/crc16_x_25.rb +3 -1
  50. data/lib/digest/crc16_xmodem.rb +2 -14
  51. data/lib/digest/crc16_zmodem.rb +2 -14
  52. data/lib/digest/crc24.rb +2 -33
  53. data/lib/digest/crc32.rb +2 -34
  54. data/lib/digest/crc32_bzip2.rb +2 -14
  55. data/lib/digest/crc32_mpeg.rb +2 -14
  56. data/lib/digest/crc32_posix.rb +2 -14
  57. data/lib/digest/crc32_xfer.rb +2 -14
  58. data/lib/digest/crc5.rb +19 -44
  59. data/lib/digest/crc64.rb +2 -38
  60. data/lib/digest/crc64_nvme.rb +90 -0
  61. data/lib/digest/crc8.rb +2 -27
  62. metadata +8 -36
  63. data/spec/crc15_spec.rb +0 -10
  64. data/spec/crc16_ccitt_spec.rb +0 -10
  65. data/spec/crc16_genibus_spec.rb +0 -10
  66. data/spec/crc16_kermit_spec.rb +0 -10
  67. data/spec/crc16_modbus_spec.rb +0 -10
  68. data/spec/crc16_qt_spec.rb +0 -10
  69. data/spec/crc16_spec.rb +0 -10
  70. data/spec/crc16_usb_spec.rb +0 -10
  71. data/spec/crc16_x_25_spec.rb +0 -10
  72. data/spec/crc16_xmodem_spec.rb +0 -10
  73. data/spec/crc16_zmodem_spec.rb +0 -10
  74. data/spec/crc1_spec.rb +0 -10
  75. data/spec/crc24_spec.rb +0 -10
  76. data/spec/crc32_bzip2_spec.rb +0 -10
  77. data/spec/crc32_jam_spec.rb +0 -10
  78. data/spec/crc32_mpeg_spec.rb +0 -16
  79. data/spec/crc32_posix_spec.rb +0 -10
  80. data/spec/crc32_spec.rb +0 -10
  81. data/spec/crc32_xfer_spec.rb +0 -10
  82. data/spec/crc32c_spec.rb +0 -10
  83. data/spec/crc5_spec.rb +0 -12
  84. data/spec/crc64_jones_spec.rb +0 -10
  85. data/spec/crc64_spec.rb +0 -10
  86. data/spec/crc64_xz_spec.rb +0 -10
  87. data/spec/crc8_1wire_spec.rb +0 -16
  88. data/spec/crc8_spec.rb +0 -10
  89. data/spec/crc_examples.rb +0 -27
  90. data/spec/crc_spec.rb +0 -72
  91. data/spec/integration/docker/Dockerfile.base +0 -9
  92. data/spec/integration/docker/Dockerfile.with-gcc +0 -3
  93. data/spec/integration/docker/Dockerfile.with-gcc-and-make +0 -3
  94. data/spec/integration/install_spec.rb +0 -59
  95. data/spec/spec_helper.rb +0 -1
data/lib/digest/crc5.rb CHANGED
@@ -8,30 +8,32 @@ module Digest
8
8
 
9
9
  WIDTH = 5
10
10
 
11
+ REFLECT_INPUT = true
12
+
11
13
  INIT_CRC = 0x1f
12
14
 
13
15
  XOR_MASK = 0x1f
14
16
 
15
- CRC_MASK = (0x1f << 3)
17
+ CRC_MASK = 0x1f
16
18
 
17
19
  # Generated by `./pycrc.py --algorithm=table-driven --model=crc-5 --generate=c`
18
20
  TABLE = [
19
- 0x00, 0x70, 0xe0, 0x90, 0x88, 0xf8, 0x68, 0x18, 0x58, 0x28, 0xb8, 0xc8, 0xd0, 0xa0, 0x30, 0x40,
20
- 0xb0, 0xc0, 0x50, 0x20, 0x38, 0x48, 0xd8, 0xa8, 0xe8, 0x98, 0x08, 0x78, 0x60, 0x10, 0x80, 0xf0,
21
- 0x28, 0x58, 0xc8, 0xb8, 0xa0, 0xd0, 0x40, 0x30, 0x70, 0x00, 0x90, 0xe0, 0xf8, 0x88, 0x18, 0x68,
22
- 0x98, 0xe8, 0x78, 0x08, 0x10, 0x60, 0xf0, 0x80, 0xc0, 0xb0, 0x20, 0x50, 0x48, 0x38, 0xa8, 0xd8,
23
- 0x50, 0x20, 0xb0, 0xc0, 0xd8, 0xa8, 0x38, 0x48, 0x08, 0x78, 0xe8, 0x98, 0x80, 0xf0, 0x60, 0x10,
24
- 0xe0, 0x90, 0x00, 0x70, 0x68, 0x18, 0x88, 0xf8, 0xb8, 0xc8, 0x58, 0x28, 0x30, 0x40, 0xd0, 0xa0,
25
- 0x78, 0x08, 0x98, 0xe8, 0xf0, 0x80, 0x10, 0x60, 0x20, 0x50, 0xc0, 0xb0, 0xa8, 0xd8, 0x48, 0x38,
26
- 0xc8, 0xb8, 0x28, 0x58, 0x40, 0x30, 0xa0, 0xd0, 0x90, 0xe0, 0x70, 0x00, 0x18, 0x68, 0xf8, 0x88,
27
- 0xa0, 0xd0, 0x40, 0x30, 0x28, 0x58, 0xc8, 0xb8, 0xf8, 0x88, 0x18, 0x68, 0x70, 0x00, 0x90, 0xe0,
28
- 0x10, 0x60, 0xf0, 0x80, 0x98, 0xe8, 0x78, 0x08, 0x48, 0x38, 0xa8, 0xd8, 0xc0, 0xb0, 0x20, 0x50,
29
- 0x88, 0xf8, 0x68, 0x18, 0x00, 0x70, 0xe0, 0x90, 0xd0, 0xa0, 0x30, 0x40, 0x58, 0x28, 0xb8, 0xc8,
30
- 0x38, 0x48, 0xd8, 0xa8, 0xb0, 0xc0, 0x50, 0x20, 0x60, 0x10, 0x80, 0xf0, 0xe8, 0x98, 0x08, 0x78,
31
- 0xf0, 0x80, 0x10, 0x60, 0x78, 0x08, 0x98, 0xe8, 0xa8, 0xd8, 0x48, 0x38, 0x20, 0x50, 0xc0, 0xb0,
32
- 0x40, 0x30, 0xa0, 0xd0, 0xc8, 0xb8, 0x28, 0x58, 0x18, 0x68, 0xf8, 0x88, 0x90, 0xe0, 0x70, 0x00,
33
- 0xd8, 0xa8, 0x38, 0x48, 0x50, 0x20, 0xb0, 0xc0, 0x80, 0xf0, 0x60, 0x10, 0x08, 0x78, 0xe8, 0x98,
34
- 0x68, 0x18, 0x88, 0xf8, 0xe0, 0x90, 0x00, 0x70, 0x30, 0x40, 0xd0, 0xa0, 0xb8, 0xc8, 0x58, 0x28
21
+ 0x00, 0x0e, 0x1c, 0x12, 0x11, 0x1f, 0x0d, 0x03, 0x0b, 0x05, 0x17, 0x19, 0x1a, 0x14, 0x06, 0x08,
22
+ 0x16, 0x18, 0x0a, 0x04, 0x07, 0x09, 0x1b, 0x15, 0x1d, 0x13, 0x01, 0x0f, 0x0c, 0x02, 0x10, 0x1e,
23
+ 0x05, 0x0b, 0x19, 0x17, 0x14, 0x1a, 0x08, 0x06, 0x0e, 0x00, 0x12, 0x1c, 0x1f, 0x11, 0x03, 0x0d,
24
+ 0x13, 0x1d, 0x0f, 0x01, 0x02, 0x0c, 0x1e, 0x10, 0x18, 0x16, 0x04, 0x0a, 0x09, 0x07, 0x15, 0x1b,
25
+ 0x0a, 0x04, 0x16, 0x18, 0x1b, 0x15, 0x07, 0x09, 0x01, 0x0f, 0x1d, 0x13, 0x10, 0x1e, 0x0c, 0x02,
26
+ 0x1c, 0x12, 0x00, 0x0e, 0x0d, 0x03, 0x11, 0x1f, 0x17, 0x19, 0x0b, 0x05, 0x06, 0x08, 0x1a, 0x14,
27
+ 0x0f, 0x01, 0x13, 0x1d, 0x1e, 0x10, 0x02, 0x0c, 0x04, 0x0a, 0x18, 0x16, 0x15, 0x1b, 0x09, 0x07,
28
+ 0x19, 0x17, 0x05, 0x0b, 0x08, 0x06, 0x14, 0x1a, 0x12, 0x1c, 0x0e, 0x00, 0x03, 0x0d, 0x1f, 0x11,
29
+ 0x14, 0x1a, 0x08, 0x06, 0x05, 0x0b, 0x19, 0x17, 0x1f, 0x11, 0x03, 0x0d, 0x0e, 0x00, 0x12, 0x1c,
30
+ 0x02, 0x0c, 0x1e, 0x10, 0x13, 0x1d, 0x0f, 0x01, 0x09, 0x07, 0x15, 0x1b, 0x18, 0x16, 0x04, 0x0a,
31
+ 0x11, 0x1f, 0x0d, 0x03, 0x00, 0x0e, 0x1c, 0x12, 0x1a, 0x14, 0x06, 0x08, 0x0b, 0x05, 0x17, 0x19,
32
+ 0x07, 0x09, 0x1b, 0x15, 0x16, 0x18, 0x0a, 0x04, 0x0c, 0x02, 0x10, 0x1e, 0x1d, 0x13, 0x01, 0x0f,
33
+ 0x1e, 0x10, 0x02, 0x0c, 0x0f, 0x01, 0x13, 0x1d, 0x15, 0x1b, 0x09, 0x07, 0x04, 0x0a, 0x18, 0x16,
34
+ 0x08, 0x06, 0x14, 0x1a, 0x19, 0x17, 0x05, 0x0b, 0x03, 0x0d, 0x1f, 0x11, 0x12, 0x1c, 0x0e, 0x00,
35
+ 0x1b, 0x15, 0x07, 0x09, 0x0a, 0x04, 0x16, 0x18, 0x10, 0x1e, 0x0c, 0x02, 0x01, 0x0f, 0x1d, 0x13,
36
+ 0x0d, 0x03, 0x11, 0x1f, 0x1c, 0x12, 0x00, 0x0e, 0x06, 0x08, 0x1a, 0x14, 0x17, 0x19, 0x0b, 0x05
35
37
  ].freeze
36
38
 
37
39
  #
@@ -43,33 +45,6 @@ module Digest
43
45
  super
44
46
  end
45
47
 
46
- #
47
- # Packs the CRC8 checksum.
48
- #
49
- # @param [Integer] crc
50
- # The checksum to pack.
51
- #
52
- # @return [String]
53
- # The packed checksum.
54
- #
55
- def self.pack(crc)
56
- (crc & CRC_MASK).chr
57
- end
58
-
59
- #
60
- # Updates the CRC5 checksum.
61
- #
62
- # @param [String] data
63
- # The data to update the checksum with.
64
- #
65
- def update(data)
66
- data.each_byte do |b|
67
- @crc = ((@table[((@crc >> 3) ^ b) & 0xff] ^ (@crc >> 8)) & @crc_mask)
68
- end
69
-
70
- return self
71
- end
72
-
73
48
  end
74
49
  end
75
50
 
data/lib/digest/crc64.rb CHANGED
@@ -8,6 +8,8 @@ module Digest
8
8
 
9
9
  WIDTH = 64
10
10
 
11
+ REFLECT_INPUT = true
12
+
11
13
  INIT_CRC = 0x0000000000000000
12
14
 
13
15
  XOR_MASK = 0x0000000000000000
@@ -80,44 +82,6 @@ module Digest
80
82
  0x9240000000000000, 0x93f0000000000000, 0x9120000000000000, 0x9090000000000000
81
83
  ].freeze
82
84
 
83
- #
84
- # Packs the CRC64 checksum.
85
- #
86
- # @param [Integer] crc
87
- # The checksum to pack.
88
- #
89
- # @return [String]
90
- # The packed checksum.
91
- #
92
- def self.pack(crc)
93
- buffer = ''
94
-
95
- buffer << ((crc & 0xff00000000000000) >> 56).chr
96
- buffer << ((crc & 0xff000000000000) >> 48).chr
97
- buffer << ((crc & 0xff0000000000) >> 40).chr
98
- buffer << ((crc & 0xff00000000) >> 32).chr
99
- buffer << ((crc & 0xff000000) >> 24).chr
100
- buffer << ((crc & 0xff0000) >> 16).chr
101
- buffer << ((crc & 0xff00) >> 8).chr
102
- buffer << (crc & 0xff).chr
103
-
104
- buffer
105
- end
106
-
107
- #
108
- # Updates the CRC64 checksum.
109
- #
110
- # @param [String] data
111
- # The data to update the checksum with.
112
- #
113
- def update(data)
114
- data.each_byte do |b|
115
- @crc = ((@table[(@crc ^ b) & 0xff] ^ (@crc >> 8)) & 0xffffffffffffffff)
116
- end
117
-
118
- return self
119
- end
120
-
121
85
  end
122
86
  end
123
87
 
@@ -0,0 +1,90 @@
1
+ require 'digest/crc64'
2
+
3
+ module Digest
4
+ #
5
+ # Implements the CRC64 NVMe algorithm.
6
+ #
7
+ # @since 0.7.0
8
+ #
9
+ class CRC64NVMe < CRC64
10
+
11
+ INIT_XOR = 0xffffffffffffffff
12
+
13
+ INIT_CRC = 0x0 ^ INIT_XOR
14
+
15
+ XOR_MASK = 0xffffffffffffffff
16
+
17
+ # Generated by `./pycrc.py --algorithm=table-driven --width 64 --poly 0xad93d23594c93659 --reflect-in True --xor-in 0xffffffffffffffff --reflect-out True --xor-out 0xffffffffffffffff --generate=c`
18
+ TABLE = [
19
+ 0x0000000000000000, 0x7f6ef0c830358979, 0xfedde190606b12f2, 0x81b31158505e9b8b,
20
+ 0xc962e5739841b68f, 0xb60c15bba8743ff6, 0x37bf04e3f82aa47d, 0x48d1f42bc81f2d04,
21
+ 0xa61cecb46814fe75, 0xd9721c7c5821770c, 0x58c10d24087fec87, 0x27affdec384a65fe,
22
+ 0x6f7e09c7f05548fa, 0x1010f90fc060c183, 0x91a3e857903e5a08, 0xeecd189fa00bd371,
23
+ 0x78e0ff3b88be6f81, 0x078e0ff3b88be6f8, 0x863d1eabe8d57d73, 0xf953ee63d8e0f40a,
24
+ 0xb1821a4810ffd90e, 0xceecea8020ca5077, 0x4f5ffbd87094cbfc, 0x30310b1040a14285,
25
+ 0xdefc138fe0aa91f4, 0xa192e347d09f188d, 0x2021f21f80c18306, 0x5f4f02d7b0f40a7f,
26
+ 0x179ef6fc78eb277b, 0x68f0063448deae02, 0xe943176c18803589, 0x962de7a428b5bcf0,
27
+ 0xf1c1fe77117cdf02, 0x8eaf0ebf2149567b, 0x0f1c1fe77117cdf0, 0x7072ef2f41224489,
28
+ 0x38a31b04893d698d, 0x47cdebccb908e0f4, 0xc67efa94e9567b7f, 0xb9100a5cd963f206,
29
+ 0x57dd12c379682177, 0x28b3e20b495da80e, 0xa900f35319033385, 0xd66e039b2936bafc,
30
+ 0x9ebff7b0e12997f8, 0xe1d10778d11c1e81, 0x606216208142850a, 0x1f0ce6e8b1770c73,
31
+ 0x8921014c99c2b083, 0xf64ff184a9f739fa, 0x77fce0dcf9a9a271, 0x08921014c99c2b08,
32
+ 0x4043e43f0183060c, 0x3f2d14f731b68f75, 0xbe9e05af61e814fe, 0xc1f0f56751dd9d87,
33
+ 0x2f3dedf8f1d64ef6, 0x50531d30c1e3c78f, 0xd1e00c6891bd5c04, 0xae8efca0a188d57d,
34
+ 0xe65f088b6997f879, 0x9931f84359a27100, 0x1882e91b09fcea8b, 0x67ec19d339c963f2,
35
+ 0xd75adabd7a6e2d6f, 0xa8342a754a5ba416, 0x29873b2d1a053f9d, 0x56e9cbe52a30b6e4,
36
+ 0x1e383fcee22f9be0, 0x6156cf06d21a1299, 0xe0e5de5e82448912, 0x9f8b2e96b271006b,
37
+ 0x71463609127ad31a, 0x0e28c6c1224f5a63, 0x8f9bd7997211c1e8, 0xf0f5275142244891,
38
+ 0xb824d37a8a3b6595, 0xc74a23b2ba0eecec, 0x46f932eaea507767, 0x3997c222da65fe1e,
39
+ 0xafba2586f2d042ee, 0xd0d4d54ec2e5cb97, 0x5167c41692bb501c, 0x2e0934dea28ed965,
40
+ 0x66d8c0f56a91f461, 0x19b6303d5aa47d18, 0x980521650afae693, 0xe76bd1ad3acf6fea,
41
+ 0x09a6c9329ac4bc9b, 0x76c839faaaf135e2, 0xf77b28a2faafae69, 0x8815d86aca9a2710,
42
+ 0xc0c42c4102850a14, 0xbfaadc8932b0836d, 0x3e19cdd162ee18e6, 0x41773d1952db919f,
43
+ 0x269b24ca6b12f26d, 0x59f5d4025b277b14, 0xd846c55a0b79e09f, 0xa72835923b4c69e6,
44
+ 0xeff9c1b9f35344e2, 0x90973171c366cd9b, 0x1124202993385610, 0x6e4ad0e1a30ddf69,
45
+ 0x8087c87e03060c18, 0xffe938b633338561, 0x7e5a29ee636d1eea, 0x0134d92653589793,
46
+ 0x49e52d0d9b47ba97, 0x368bddc5ab7233ee, 0xb738cc9dfb2ca865, 0xc8563c55cb19211c,
47
+ 0x5e7bdbf1e3ac9dec, 0x21152b39d3991495, 0xa0a63a6183c78f1e, 0xdfc8caa9b3f20667,
48
+ 0x97193e827bed2b63, 0xe877ce4a4bd8a21a, 0x69c4df121b863991, 0x16aa2fda2bb3b0e8,
49
+ 0xf86737458bb86399, 0x8709c78dbb8deae0, 0x06bad6d5ebd3716b, 0x79d4261ddbe6f812,
50
+ 0x3105d23613f9d516, 0x4e6b22fe23cc5c6f, 0xcfd833a67392c7e4, 0xb0b6c36e43a74e9d,
51
+ 0x9a6c9329ac4bc9b5, 0xe50263e19c7e40cc, 0x64b172b9cc20db47, 0x1bdf8271fc15523e,
52
+ 0x530e765a340a7f3a, 0x2c608692043ff643, 0xadd397ca54616dc8, 0xd2bd67026454e4b1,
53
+ 0x3c707f9dc45f37c0, 0x431e8f55f46abeb9, 0xc2ad9e0da4342532, 0xbdc36ec59401ac4b,
54
+ 0xf5129aee5c1e814f, 0x8a7c6a266c2b0836, 0x0bcf7b7e3c7593bd, 0x74a18bb60c401ac4,
55
+ 0xe28c6c1224f5a634, 0x9de29cda14c02f4d, 0x1c518d82449eb4c6, 0x633f7d4a74ab3dbf,
56
+ 0x2bee8961bcb410bb, 0x548079a98c8199c2, 0xd53368f1dcdf0249, 0xaa5d9839ecea8b30,
57
+ 0x449080a64ce15841, 0x3bfe706e7cd4d138, 0xba4d61362c8a4ab3, 0xc52391fe1cbfc3ca,
58
+ 0x8df265d5d4a0eece, 0xf29c951de49567b7, 0x732f8445b4cbfc3c, 0x0c41748d84fe7545,
59
+ 0x6bad6d5ebd3716b7, 0x14c39d968d029fce, 0x95708ccedd5c0445, 0xea1e7c06ed698d3c,
60
+ 0xa2cf882d2576a038, 0xdda178e515432941, 0x5c1269bd451db2ca, 0x237c997575283bb3,
61
+ 0xcdb181ead523e8c2, 0xb2df7122e51661bb, 0x336c607ab548fa30, 0x4c0290b2857d7349,
62
+ 0x04d364994d625e4d, 0x7bbd94517d57d734, 0xfa0e85092d094cbf, 0x856075c11d3cc5c6,
63
+ 0x134d926535897936, 0x6c2362ad05bcf04f, 0xed9073f555e26bc4, 0x92fe833d65d7e2bd,
64
+ 0xda2f7716adc8cfb9, 0xa54187de9dfd46c0, 0x24f29686cda3dd4b, 0x5b9c664efd965432,
65
+ 0xb5517ed15d9d8743, 0xca3f8e196da80e3a, 0x4b8c9f413df695b1, 0x34e26f890dc31cc8,
66
+ 0x7c339ba2c5dc31cc, 0x035d6b6af5e9b8b5, 0x82ee7a32a5b7233e, 0xfd808afa9582aa47,
67
+ 0x4d364994d625e4da, 0x3258b95ce6106da3, 0xb3eba804b64ef628, 0xcc8558cc867b7f51,
68
+ 0x8454ace74e645255, 0xfb3a5c2f7e51db2c, 0x7a894d772e0f40a7, 0x05e7bdbf1e3ac9de,
69
+ 0xeb2aa520be311aaf, 0x944455e88e0493d6, 0x15f744b0de5a085d, 0x6a99b478ee6f8124,
70
+ 0x224840532670ac20, 0x5d26b09b16452559, 0xdc95a1c3461bbed2, 0xa3fb510b762e37ab,
71
+ 0x35d6b6af5e9b8b5b, 0x4ab846676eae0222, 0xcb0b573f3ef099a9, 0xb465a7f70ec510d0,
72
+ 0xfcb453dcc6da3dd4, 0x83daa314f6efb4ad, 0x0269b24ca6b12f26, 0x7d0742849684a65f,
73
+ 0x93ca5a1b368f752e, 0xeca4aad306bafc57, 0x6d17bb8b56e467dc, 0x12794b4366d1eea5,
74
+ 0x5aa8bf68aecec3a1, 0x25c64fa09efb4ad8, 0xa4755ef8cea5d153, 0xdb1bae30fe90582a,
75
+ 0xbcf7b7e3c7593bd8, 0xc399472bf76cb2a1, 0x422a5673a732292a, 0x3d44a6bb9707a053,
76
+ 0x759552905f188d57, 0x0afba2586f2d042e, 0x8b48b3003f739fa5, 0xf42643c80f4616dc,
77
+ 0x1aeb5b57af4dc5ad, 0x6585ab9f9f784cd4, 0xe436bac7cf26d75f, 0x9b584a0fff135e26,
78
+ 0xd389be24370c7322, 0xace74eec0739fa5b, 0x2d545fb4576761d0, 0x523aaf7c6752e8a9,
79
+ 0xc41748d84fe75459, 0xbb79b8107fd2dd20, 0x3acaa9482f8c46ab, 0x45a459801fb9cfd2,
80
+ 0x0d75adabd7a6e2d6, 0x721b5d63e7936baf, 0xf3a84c3bb7cdf024, 0x8cc6bcf387f8795d,
81
+ 0x620ba46c27f3aa2c, 0x1d6554a417c62355, 0x9cd645fc4798b8de, 0xe3b8b53477ad31a7,
82
+ 0xab69411fbfb21ca3, 0xd407b1d78f8795da, 0x55b4a08fdfd90e51, 0x2ada5047efec8728
83
+ ].freeze
84
+
85
+ end
86
+ end
87
+
88
+ if RUBY_ENGINE == 'ruby'
89
+ begin; require 'digest/crc64_nvme/crc64_nvme_ext'; rescue LoadError; end
90
+ end
data/lib/digest/crc8.rb CHANGED
@@ -8,6 +8,8 @@ module Digest
8
8
 
9
9
  WIDTH = 8
10
10
 
11
+ REFLECT_INPUT = false
12
+
11
13
  INIT_CRC = 0x00
12
14
 
13
15
  # Generated by `./pycrc.py --algorithm=table-driven --model=crc-8 --generate=c`
@@ -30,33 +32,6 @@ module Digest
30
32
  0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3
31
33
  ].freeze
32
34
 
33
- #
34
- # Packs the CRC8 checksum.
35
- #
36
- # @param [Integer] crc
37
- # The checksum to pack.
38
- #
39
- # @return [String]
40
- # The packed checksum.
41
- #
42
- def self.pack(crc)
43
- (crc & 0xff).chr
44
- end
45
-
46
- #
47
- # Updates the CRC8 checksum.
48
- #
49
- # @param [String] data
50
- # The data to update the checksum with.
51
- #
52
- def update(data)
53
- data.each_byte do |b|
54
- @crc = ((@table[(@crc ^ b) & 0xff] ^ (@crc << 8)) & 0xff)
55
- end
56
-
57
- return self
58
- end
59
-
60
35
  end
61
36
  end
62
37
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: digest-crc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-25 00:00:00.000000000 Z
11
+ date: 2025-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -161,6 +161,10 @@ files:
161
161
  - ext/digest/crc64_jones/crc64_jones.h
162
162
  - ext/digest/crc64_jones/crc64_jones_ext.c
163
163
  - ext/digest/crc64_jones/extconf.rb
164
+ - ext/digest/crc64_nvme/crc64_nvme.c
165
+ - ext/digest/crc64_nvme/crc64_nvme.h
166
+ - ext/digest/crc64_nvme/crc64_nvme_ext.c
167
+ - ext/digest/crc64_nvme/extconf.rb
164
168
  - ext/digest/crc64_xz/crc64_xz.c
165
169
  - ext/digest/crc64_xz/crc64_xz.h
166
170
  - ext/digest/crc64_xz/crc64_xz_ext.c
@@ -199,42 +203,10 @@ files:
199
203
  - lib/digest/crc5.rb
200
204
  - lib/digest/crc64.rb
201
205
  - lib/digest/crc64_jones.rb
206
+ - lib/digest/crc64_nvme.rb
202
207
  - lib/digest/crc64_xz.rb
203
208
  - lib/digest/crc8.rb
204
209
  - lib/digest/crc8_1wire.rb
205
- - spec/crc15_spec.rb
206
- - spec/crc16_ccitt_spec.rb
207
- - spec/crc16_genibus_spec.rb
208
- - spec/crc16_kermit_spec.rb
209
- - spec/crc16_modbus_spec.rb
210
- - spec/crc16_qt_spec.rb
211
- - spec/crc16_spec.rb
212
- - spec/crc16_usb_spec.rb
213
- - spec/crc16_x_25_spec.rb
214
- - spec/crc16_xmodem_spec.rb
215
- - spec/crc16_zmodem_spec.rb
216
- - spec/crc1_spec.rb
217
- - spec/crc24_spec.rb
218
- - spec/crc32_bzip2_spec.rb
219
- - spec/crc32_jam_spec.rb
220
- - spec/crc32_mpeg_spec.rb
221
- - spec/crc32_posix_spec.rb
222
- - spec/crc32_spec.rb
223
- - spec/crc32_xfer_spec.rb
224
- - spec/crc32c_spec.rb
225
- - spec/crc5_spec.rb
226
- - spec/crc64_jones_spec.rb
227
- - spec/crc64_spec.rb
228
- - spec/crc64_xz_spec.rb
229
- - spec/crc8_1wire_spec.rb
230
- - spec/crc8_spec.rb
231
- - spec/crc_examples.rb
232
- - spec/crc_spec.rb
233
- - spec/integration/docker/Dockerfile.base
234
- - spec/integration/docker/Dockerfile.with-gcc
235
- - spec/integration/docker/Dockerfile.with-gcc-and-make
236
- - spec/integration/install_spec.rb
237
- - spec/spec_helper.rb
238
210
  homepage: https://github.com/postmodern/digest-crc#readme
239
211
  licenses:
240
212
  - MIT
@@ -259,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
231
  - !ruby/object:Gem::Version
260
232
  version: '0'
261
233
  requirements: []
262
- rubygems_version: 3.2.22
234
+ rubygems_version: 3.5.22
263
235
  signing_key:
264
236
  specification_version: 4
265
237
  summary: A Cyclic Redundancy Check (CRC) library for Ruby.
data/spec/crc15_spec.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc15'
4
-
5
- describe Digest::CRC15 do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '178c' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc16_ccitt'
4
-
5
- describe Digest::CRC16CCITT do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '3218' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc16_genibus'
4
-
5
- describe Digest::CRC16Genibus do
6
- let(:string) { '1234567890' }
7
- let(:expected) { 'cde7' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc16_kermit'
4
-
5
- describe Digest::CRC16Kermit do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '286b' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc16_modbus'
4
-
5
- describe Digest::CRC16Modbus do
6
- let(:string) { '1234567890' }
7
- let(:expected) { 'c20a' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'digest/crc16_qt'
3
-
4
- describe "Digest::CRC16QT" do
5
- subject { Digest::CRC16QT }
6
-
7
- it "should be an alias to Digest::CRC16X25" do
8
- expect(subject).to be < Digest::CRC16X25
9
- end
10
- end
data/spec/crc16_spec.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc16'
4
-
5
- describe Digest::CRC16 do
6
- let(:string) { '1234567890' }
7
- let(:expected) { 'c57a' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc16_usb'
4
-
5
- describe Digest::CRC16USB do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '3df5' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc16_x_25'
4
-
5
- describe Digest::CRC16X25 do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '4b13' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc16_xmodem'
4
-
5
- describe Digest::CRC16XModem do
6
- let(:string) { '1234567890' }
7
- let(:expected) { 'd321' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc16_zmodem'
4
-
5
- describe Digest::CRC16ZModem do
6
- let(:string) { '1234567890' }
7
- let(:expected) { 'd321' }
8
-
9
- it_should_behave_like "CRC"
10
- end
data/spec/crc1_spec.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc1'
4
-
5
- describe Digest::CRC1 do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '0d' }
8
-
9
- it_should_behave_like "CRC"
10
- end
data/spec/crc24_spec.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc24'
4
-
5
- describe Digest::CRC24 do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '8c0072' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc32_bzip2'
4
-
5
- describe Digest::CRC32BZip2 do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '506853b6' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc32_jam'
4
-
5
- describe Digest::CRC32Jam do
6
- let(:string) { '1234567890' }
7
- let(:expected) { 'd9e2511a' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc32_mpeg'
4
-
5
- describe Digest::CRC32MPEG do
6
- let(:string) { '1234567890' }
7
- let(:expected) { 'af97ac49' }
8
-
9
- it_should_behave_like "CRC"
10
- end
11
-
12
- describe "Digest::CRC32Mpeg" do
13
- subject { Digest::CRC32Mpeg }
14
-
15
- it { expect(subject).to eq(Digest::CRC32MPEG) }
16
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc32_posix'
4
-
5
- describe Digest::CRC32POSIX do
6
- let(:string) { '1234567890' }
7
- let(:expected) { 'c181fd8e' }
8
-
9
- it_should_behave_like "CRC"
10
- end
data/spec/crc32_spec.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc32'
4
-
5
- describe Digest::CRC32 do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '261daee5' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc32_xfer'
4
-
5
- describe Digest::CRC32XFER do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '0be368eb' }
8
-
9
- it_should_behave_like "CRC"
10
- end
data/spec/crc32c_spec.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc32c'
4
-
5
- describe Digest::CRC32c do
6
- let(:string) { '1234567890' }
7
- let(:expected) { 'f3dbd4fe' }
8
-
9
- it_should_behave_like "CRC"
10
- end
data/spec/crc5_spec.rb DELETED
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc5'
4
-
5
- describe Digest::CRC5 do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '1' }
8
-
9
- pending "Implementation of CRC5 does not match pycrc.py" do
10
- it_should_behave_like "CRC"
11
- end
12
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc64_jones'
4
-
5
- describe Digest::CRC64Jones do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '68a745ba133af9bd' }
8
-
9
- it_should_behave_like "CRC"
10
- end
data/spec/crc64_spec.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc64'
4
-
5
- describe Digest::CRC64 do
6
- let(:string) { '1234567890' }
7
- let(:expected) { 'bc66a5a9388a5bef' }
8
-
9
- it_should_behave_like "CRC"
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc64_xz'
4
-
5
- describe Digest::CRC64XZ do
6
- let(:string) { '1234567890' }
7
- let(:expected) { 'b1cb31bbb4a2b2be' }
8
-
9
- it_should_behave_like "CRC"
10
- end