digest-crc 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +5 -5
  3. data/ChangeLog.md +5 -0
  4. data/Gemfile +2 -1
  5. data/ext/digest/crc12_3gpp/crc12_3gpp_ext.c +4 -0
  6. data/ext/digest/crc15/crc15_ext.c +4 -0
  7. data/ext/digest/crc16/crc16_ext.c +4 -0
  8. data/ext/digest/crc16_ccitt/crc16_ccitt_ext.c +4 -0
  9. data/ext/digest/crc16_dnp/crc16_dnp_ext.c +4 -0
  10. data/ext/digest/crc16_genibus/crc16_genibus_ext.c +4 -0
  11. data/ext/digest/crc16_kermit/crc16_kermit_ext.c +4 -0
  12. data/ext/digest/crc16_modbus/crc16_modbus_ext.c +4 -1
  13. data/ext/digest/crc16_usb/crc16_usb_ext.c +4 -1
  14. data/ext/digest/crc16_x_25/crc16_x_25_ext.c +4 -1
  15. data/ext/digest/crc16_xmodem/crc16_xmodem_ext.c +4 -0
  16. data/ext/digest/crc16_zmodem/crc16_zmodem_ext.c +4 -0
  17. data/ext/digest/crc24/crc24_ext.c +4 -0
  18. data/ext/digest/crc32/crc32_ext.c +4 -0
  19. data/ext/digest/crc32_bzip2/crc32_bzip2_ext.c +4 -0
  20. data/ext/digest/crc32_jam/crc32_jam_ext.c +4 -1
  21. data/ext/digest/crc32_mpeg/crc32_mpeg_ext.c +4 -0
  22. data/ext/digest/crc32_posix/crc32_posix_ext.c +4 -0
  23. data/ext/digest/crc32_xfer/crc32_xfer_ext.c +4 -0
  24. data/ext/digest/crc32c/crc32c_ext.c +4 -1
  25. data/ext/digest/crc5/crc5_ext.c +4 -0
  26. data/ext/digest/crc64/crc64_ext.c +4 -0
  27. data/ext/digest/crc64_jones/crc64_jones_ext.c +4 -1
  28. data/ext/digest/crc64_xz/crc64_xz_ext.c +4 -1
  29. data/ext/digest/crc8/crc8_ext.c +4 -0
  30. data/ext/digest/crc8_1wire/crc8_1wire_ext.c +4 -1
  31. data/gemspec.yml +1 -1
  32. data/lib/digest/crc5.rb +18 -18
  33. data/spec/crc5_spec.rb +2 -4
  34. data/spec/crc_examples.rb +10 -0
  35. data/spec/spec_helper.rb +2 -0
  36. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60d4a283607198107ef66cb7e090570f5793c16c9641c791aff8a054d226655f
4
- data.tar.gz: 4f4fb5821e6111d17e087a4160ea8f09a5cfd316324ae797f7a61be7cacd337a
3
+ metadata.gz: a91420951947a2ed738b2b786ab0c22105124fa9c92fa2cbaebf5664abd8b8e4
4
+ data.tar.gz: b46f6cc23d7d6e300d55524a31d4cb4c331bd3c0489819c56d6f05e60c6246bc
5
5
  SHA512:
6
- metadata.gz: '07919fa492ae97de8969e359ec02bd57a0525665cfc8bbca69203f76e1a20593611bc6aa20840fca3672f4f1e592b608282ea85222dcafa88ab44d07fbc5433f'
7
- data.tar.gz: 790f52517a7abd4b24eef5d17fa168d53c9392775b2baba1e496703391f84704944eb8a0651c37fd7c3be3766e32d07609b0c0adf9877e188c02995ed2244105
6
+ metadata.gz: ce767424edcbdf407a449b6f3dc3f31bf3cb60f240bbaf47d4bc8754da13d913b05644bc77e73c892f419e289cdde52651496c67d72a754d7d562528a9c3a64a
7
+ data.tar.gz: 334b17ae6e0e36546cf99617d9a0f4e2bf826bb1db578f4a8c4f556f66edf9585f00fe21b5e69865105e873e50a458e820ede34ddf204883858def40dbdfff4b
@@ -12,12 +12,12 @@ jobs:
12
12
  - ubuntu-latest
13
13
  - macos-latest
14
14
  ruby:
15
- - 2.4
16
- - 2.5
17
- - 2.6
18
- - 2.7
19
- - 3.0
15
+ - '2.7'
16
+ - '3.0'
17
+ - '3.1'
18
+ - '3.2.0-preview1'
20
19
  - jruby
20
+ - truffleruby
21
21
  name: OS ${{ matrix.os }} / Ruby ${{ matrix.ruby }}
22
22
  steps:
23
23
  - uses: actions/checkout@v2
data/ChangeLog.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.6.5 / 2023-07-03
2
+
3
+ * Corrected the implementation of {Digest::CRC5}.
4
+ * Make `digest-crc` Ractor-safe.
5
+
1
6
  ### 0.6.4 / 2021-07-14
2
7
 
3
8
  * Silence potential method redefinition warnings when loading the C extensions.
data/Gemfile CHANGED
@@ -6,7 +6,8 @@ group :development do
6
6
  gem 'rake'
7
7
  gem 'rubygems-tasks', '~> 0.2'
8
8
 
9
- gem 'rspec', '~> 3.0'
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'simplecov', '~> 0.20'
10
11
 
11
12
  gem 'yard', '~> 0.9'
12
13
  gem 'kramdown'
@@ -23,6 +23,10 @@ void Init_crc12_3gpp_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC12_3GPP = rb_const_get(mDigest, rb_intern("CRC12_3GPP"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_undef_method(cCRC12_3GPP, "update");
27
31
  rb_define_method(cCRC12_3GPP, "update", Digest_CRC12_3GPP_update, 1);
28
32
  }
@@ -24,6 +24,10 @@ void Init_crc15_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC15 = rb_const_get(mDigest, rb_intern("CRC15"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
27
31
  rb_undef_method(cCRC15, "update");
28
32
  rb_define_method(cCRC15, "update", Digest_CRC15_update, 1);
29
33
  }
@@ -24,6 +24,10 @@ void Init_crc16_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16 = rb_const_get(mDigest, rb_intern("CRC16"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
27
31
  rb_undef_method(cCRC16, "update");
28
32
  rb_define_method(cCRC16, "update", Digest_CRC16_update, 1);
29
33
  }
@@ -24,6 +24,10 @@ void Init_crc16_ccitt_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16CCITT = rb_const_get(mDigest, rb_intern("CRC16CCITT"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
27
31
  rb_undef_method(cCRC16CCITT, "update");
28
32
  rb_define_method(cCRC16CCITT, "update", Digest_CRC16CCITT_update, 1);
29
33
  }
@@ -24,6 +24,10 @@ void Init_crc16_dnp_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16DNP = rb_const_get(mDigest, rb_intern("CRC16DNP"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
27
31
  rb_undef_method(cCRC16DNP, "update");
28
32
  rb_define_method(cCRC16DNP, "update", Digest_CRC16DNP_update, 1);
29
33
  }
@@ -24,6 +24,10 @@ void Init_crc16_genibus_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16Genibus = rb_const_get(mDigest, rb_intern("CRC16Genibus"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
27
31
  rb_undef_method(cCRC16Genibus, "update");
28
32
  rb_define_method(cCRC16Genibus, "update", Digest_CRC16Genibus_update, 1);
29
33
  }
@@ -24,6 +24,10 @@ void Init_crc16_kermit_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16Kermit = rb_const_get(mDigest, rb_intern("CRC16Kermit"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
27
31
  rb_undef_method(cCRC16Kermit, "update");
28
32
  rb_define_method(cCRC16Kermit, "update", Digest_CRC16Kermit_update, 1);
29
33
  }
@@ -24,6 +24,9 @@ void Init_crc16_modbus_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16Modbus = rb_const_get(mDigest, rb_intern("CRC16Modbus"));
26
26
 
27
- rb_undef_method(cCRC16Modbus, "update");
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
28
31
  rb_define_method(cCRC16Modbus, "update", Digest_CRC16Modbus_update, 1);
29
32
  }
@@ -24,6 +24,9 @@ void Init_crc16_usb_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16USB = rb_const_get(mDigest, rb_intern("CRC16USB"));
26
26
 
27
- rb_undef_method(cCRC16USB, "update");
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
28
31
  rb_define_method(cCRC16USB, "update", Digest_CRC16USB_update, 1);
29
32
  }
@@ -24,6 +24,9 @@ void Init_crc16_x_25_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16X25 = rb_const_get(mDigest, rb_intern("CRC16X25"));
26
26
 
27
- rb_undef_method(cCRC16X25, "update");
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
28
31
  rb_define_method(cCRC16X25, "update", Digest_CRC16X25_update, 1);
29
32
  }
@@ -24,6 +24,10 @@ void Init_crc16_xmodem_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16XModem = rb_const_get(mDigest, rb_intern("CRC16XModem"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
27
31
  rb_undef_method(cCRC16XModem, "update");
28
32
  rb_define_method(cCRC16XModem, "update", Digest_CRC16XModem_update, 1);
29
33
  }
@@ -24,6 +24,10 @@ void Init_crc16_zmodem_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16ZModem = rb_const_get(mDigest, rb_intern("CRC16ZModem"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
27
31
  rb_undef_method(cCRC16ZModem, "update");
28
32
  rb_define_method(cCRC16ZModem, "update", Digest_CRC16ZModem_update, 1);
29
33
  }
@@ -23,6 +23,10 @@ void Init_crc24_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC24 = rb_const_get(mDigest, rb_intern("CRC24"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_undef_method(cCRC24, "update");
27
31
  rb_define_method(cCRC24, "update", Digest_CRC24_update, 1);
28
32
  }
@@ -23,6 +23,10 @@ void Init_crc32_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32 = rb_const_get(mDigest, rb_intern("CRC32"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_undef_method(cCRC32, "update");
27
31
  rb_define_method(cCRC32, "update", Digest_CRC32_update, 1);
28
32
  }
@@ -23,6 +23,10 @@ void Init_crc32_bzip2_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32Bzip2 = rb_const_get(mDigest, rb_intern("CRC32BZip2"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_undef_method(cCRC32Bzip2, "update");
27
31
  rb_define_method(cCRC32Bzip2, "update", Digest_CRC32Bzip2_update, 1);
28
32
  }
@@ -23,6 +23,9 @@ void Init_crc32_jam_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32Jam = rb_const_get(mDigest, rb_intern("CRC32Jam"));
25
25
 
26
- rb_undef_method(cCRC32Jam, "update");
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
27
30
  rb_define_method(cCRC32Jam, "update", Digest_CRC32Jam_update, 1);
28
31
  }
@@ -23,6 +23,10 @@ void Init_crc32_mpeg_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32MPEG = rb_const_get(mDigest, rb_intern("CRC32MPEG"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_undef_method(cCRC32MPEG, "update");
27
31
  rb_define_method(cCRC32MPEG, "update", Digest_CRC32MPEG_update, 1);
28
32
  }
@@ -23,6 +23,10 @@ void Init_crc32_posix_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32POSIX = rb_const_get(mDigest, rb_intern("CRC32POSIX"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_undef_method(cCRC32POSIX, "update");
27
31
  rb_define_method(cCRC32POSIX, "update", Digest_CRC32POSIX_update, 1);
28
32
  }
@@ -23,6 +23,10 @@ void Init_crc32_xfer_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32XFER = rb_const_get(mDigest, rb_intern("CRC32XFER"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_undef_method(cCRC32XFER, "update");
27
31
  rb_define_method(cCRC32XFER, "update", Digest_CRC32XFER_update, 1);
28
32
  }
@@ -23,6 +23,9 @@ void Init_crc32c_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32c = rb_const_get(mDigest, rb_intern("CRC32c"));
25
25
 
26
- rb_undef_method(cCRC32c, "update");
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
27
30
  rb_define_method(cCRC32c, "update", Digest_CRC32c_update, 1);
28
31
  }
@@ -23,6 +23,10 @@ void Init_crc5_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC5 = rb_const_get(mDigest, rb_intern("CRC5"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_undef_method(cCRC5, "update");
27
31
  rb_define_method(cCRC5, "update", Digest_CRC5_update, 1);
28
32
  }
@@ -23,6 +23,10 @@ void Init_crc64_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC64 = rb_const_get(mDigest, rb_intern("CRC64"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_undef_method(cCRC64, "update");
27
31
  rb_define_method(cCRC64, "update", Digest_CRC64_update, 1);
28
32
  }
@@ -23,6 +23,9 @@ void Init_crc64_jones_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC64Jones = rb_const_get(mDigest, rb_intern("CRC64Jones"));
25
25
 
26
- rb_undef_method(cCRC64Jones, "update");
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
27
30
  rb_define_method(cCRC64Jones, "update", Digest_CRC64Jones_update, 1);
28
31
  }
@@ -23,6 +23,9 @@ void Init_crc64_xz_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC64XZ = rb_const_get(mDigest, rb_intern("CRC64XZ"));
25
25
 
26
- rb_undef_method(cCRC64XZ, "update");
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
27
30
  rb_define_method(cCRC64XZ, "update", Digest_CRC64XZ_update, 1);
28
31
  }
@@ -23,6 +23,10 @@ void Init_crc8_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC8 = rb_const_get(mDigest, rb_intern("CRC8"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_undef_method(cCRC8, "update");
27
31
  rb_define_method(cCRC8, "update", Digest_CRC8_update, 1);
28
32
  }
@@ -23,6 +23,9 @@ void Init_crc8_1wire_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC81Wire = rb_const_get(mDigest, rb_intern("CRC8_1Wire"));
25
25
 
26
- rb_undef_method(cCRC81Wire, "update");
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
27
30
  rb_define_method(cCRC81Wire, "update", Digest_CRC81Wire_update, 1);
28
31
  }
data/gemspec.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  name: digest-crc
2
- version: 0.6.4
2
+ version: 0.6.5
3
3
  summary: A Cyclic Redundancy Check (CRC) library for Ruby.
4
4
  description:
5
5
  Adds support for calculating Cyclic Redundancy Check (CRC) to the Digest
data/lib/digest/crc5.rb CHANGED
@@ -12,26 +12,26 @@ module Digest
12
12
 
13
13
  XOR_MASK = 0x1f
14
14
 
15
- CRC_MASK = (0x1f << 3)
15
+ CRC_MASK = 0x1f
16
16
 
17
17
  # Generated by `./pycrc.py --algorithm=table-driven --model=crc-5 --generate=c`
18
18
  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
19
+ 0x00, 0x0e, 0x1c, 0x12, 0x11, 0x1f, 0x0d, 0x03, 0x0b, 0x05, 0x17, 0x19, 0x1a, 0x14, 0x06, 0x08,
20
+ 0x16, 0x18, 0x0a, 0x04, 0x07, 0x09, 0x1b, 0x15, 0x1d, 0x13, 0x01, 0x0f, 0x0c, 0x02, 0x10, 0x1e,
21
+ 0x05, 0x0b, 0x19, 0x17, 0x14, 0x1a, 0x08, 0x06, 0x0e, 0x00, 0x12, 0x1c, 0x1f, 0x11, 0x03, 0x0d,
22
+ 0x13, 0x1d, 0x0f, 0x01, 0x02, 0x0c, 0x1e, 0x10, 0x18, 0x16, 0x04, 0x0a, 0x09, 0x07, 0x15, 0x1b,
23
+ 0x0a, 0x04, 0x16, 0x18, 0x1b, 0x15, 0x07, 0x09, 0x01, 0x0f, 0x1d, 0x13, 0x10, 0x1e, 0x0c, 0x02,
24
+ 0x1c, 0x12, 0x00, 0x0e, 0x0d, 0x03, 0x11, 0x1f, 0x17, 0x19, 0x0b, 0x05, 0x06, 0x08, 0x1a, 0x14,
25
+ 0x0f, 0x01, 0x13, 0x1d, 0x1e, 0x10, 0x02, 0x0c, 0x04, 0x0a, 0x18, 0x16, 0x15, 0x1b, 0x09, 0x07,
26
+ 0x19, 0x17, 0x05, 0x0b, 0x08, 0x06, 0x14, 0x1a, 0x12, 0x1c, 0x0e, 0x00, 0x03, 0x0d, 0x1f, 0x11,
27
+ 0x14, 0x1a, 0x08, 0x06, 0x05, 0x0b, 0x19, 0x17, 0x1f, 0x11, 0x03, 0x0d, 0x0e, 0x00, 0x12, 0x1c,
28
+ 0x02, 0x0c, 0x1e, 0x10, 0x13, 0x1d, 0x0f, 0x01, 0x09, 0x07, 0x15, 0x1b, 0x18, 0x16, 0x04, 0x0a,
29
+ 0x11, 0x1f, 0x0d, 0x03, 0x00, 0x0e, 0x1c, 0x12, 0x1a, 0x14, 0x06, 0x08, 0x0b, 0x05, 0x17, 0x19,
30
+ 0x07, 0x09, 0x1b, 0x15, 0x16, 0x18, 0x0a, 0x04, 0x0c, 0x02, 0x10, 0x1e, 0x1d, 0x13, 0x01, 0x0f,
31
+ 0x1e, 0x10, 0x02, 0x0c, 0x0f, 0x01, 0x13, 0x1d, 0x15, 0x1b, 0x09, 0x07, 0x04, 0x0a, 0x18, 0x16,
32
+ 0x08, 0x06, 0x14, 0x1a, 0x19, 0x17, 0x05, 0x0b, 0x03, 0x0d, 0x1f, 0x11, 0x12, 0x1c, 0x0e, 0x00,
33
+ 0x1b, 0x15, 0x07, 0x09, 0x0a, 0x04, 0x16, 0x18, 0x10, 0x1e, 0x0c, 0x02, 0x01, 0x0f, 0x1d, 0x13,
34
+ 0x0d, 0x03, 0x11, 0x1f, 0x1c, 0x12, 0x00, 0x0e, 0x06, 0x08, 0x1a, 0x14, 0x17, 0x19, 0x0b, 0x05
35
35
  ].freeze
36
36
 
37
37
  #
@@ -64,7 +64,7 @@ module Digest
64
64
  #
65
65
  def update(data)
66
66
  data.each_byte do |b|
67
- @crc = ((@table[((@crc >> 3) ^ b) & 0xff] ^ (@crc >> 8)) & @crc_mask)
67
+ @crc = ((@table[(@crc ^ b) & 0xff] ^ (@crc >> 8)) & @crc_mask)
68
68
  end
69
69
 
70
70
  return self
data/spec/crc5_spec.rb CHANGED
@@ -4,9 +4,7 @@ require 'digest/crc5'
4
4
 
5
5
  describe Digest::CRC5 do
6
6
  let(:string) { '1234567890' }
7
- let(:expected) { '1' }
7
+ let(:expected) { '01' }
8
8
 
9
- pending "Implementation of CRC5 does not match pycrc.py" do
10
- it_should_behave_like "CRC"
11
- end
9
+ it_should_behave_like "CRC"
12
10
  end
data/spec/crc_examples.rb CHANGED
@@ -24,4 +24,14 @@ shared_examples_for "CRC" do
24
24
 
25
25
  expect(crc.checksum).to be == expected.to_i(16)
26
26
  end
27
+
28
+ if defined?(Ractor)
29
+ it "should calculate CRC inside ractor" do
30
+ digest = Ractor.new(described_class, string) do |klass, string|
31
+ klass.hexdigest(string)
32
+ end.take
33
+
34
+ expect(digest).to eq expected
35
+ end
36
+ end
27
37
  end
data/spec/spec_helper.rb CHANGED
@@ -1 +1,3 @@
1
1
  require 'rspec'
2
+ require 'simplecov'
3
+ SimpleCov.start
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.6.5
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: 2023-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -259,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
259
  - !ruby/object:Gem::Version
260
260
  version: '0'
261
261
  requirements: []
262
- rubygems_version: 3.2.22
262
+ rubygems_version: 3.4.10
263
263
  signing_key:
264
264
  specification_version: 4
265
265
  summary: A Cyclic Redundancy Check (CRC) library for Ruby.