digest-crc 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -5
- data/ChangeLog.md +5 -0
- data/Gemfile +2 -1
- data/ext/digest/crc12_3gpp/crc12_3gpp_ext.c +4 -0
- data/ext/digest/crc15/crc15_ext.c +4 -0
- data/ext/digest/crc16/crc16_ext.c +4 -0
- data/ext/digest/crc16_ccitt/crc16_ccitt_ext.c +4 -0
- data/ext/digest/crc16_dnp/crc16_dnp_ext.c +4 -0
- data/ext/digest/crc16_genibus/crc16_genibus_ext.c +4 -0
- data/ext/digest/crc16_kermit/crc16_kermit_ext.c +4 -0
- data/ext/digest/crc16_modbus/crc16_modbus_ext.c +4 -1
- data/ext/digest/crc16_usb/crc16_usb_ext.c +4 -1
- data/ext/digest/crc16_x_25/crc16_x_25_ext.c +4 -1
- data/ext/digest/crc16_xmodem/crc16_xmodem_ext.c +4 -0
- data/ext/digest/crc16_zmodem/crc16_zmodem_ext.c +4 -0
- data/ext/digest/crc24/crc24_ext.c +4 -0
- data/ext/digest/crc32/crc32_ext.c +4 -0
- data/ext/digest/crc32_bzip2/crc32_bzip2_ext.c +4 -0
- data/ext/digest/crc32_jam/crc32_jam_ext.c +4 -1
- data/ext/digest/crc32_mpeg/crc32_mpeg_ext.c +4 -0
- data/ext/digest/crc32_posix/crc32_posix_ext.c +4 -0
- data/ext/digest/crc32_xfer/crc32_xfer_ext.c +4 -0
- data/ext/digest/crc32c/crc32c_ext.c +4 -1
- data/ext/digest/crc5/crc5_ext.c +4 -0
- data/ext/digest/crc64/crc64_ext.c +4 -0
- data/ext/digest/crc64_jones/crc64_jones_ext.c +4 -1
- data/ext/digest/crc64_xz/crc64_xz_ext.c +4 -1
- data/ext/digest/crc8/crc8_ext.c +4 -0
- data/ext/digest/crc8_1wire/crc8_1wire_ext.c +4 -1
- data/gemspec.yml +1 -1
- data/lib/digest/crc5.rb +18 -18
- data/spec/crc5_spec.rb +2 -4
- data/spec/crc_examples.rb +10 -0
- data/spec/spec_helper.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a91420951947a2ed738b2b786ab0c22105124fa9c92fa2cbaebf5664abd8b8e4
|
4
|
+
data.tar.gz: b46f6cc23d7d6e300d55524a31d4cb4c331bd3c0489819c56d6f05e60c6246bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce767424edcbdf407a449b6f3dc3f31bf3cb60f240bbaf47d4bc8754da13d913b05644bc77e73c892f419e289cdde52651496c67d72a754d7d562528a9c3a64a
|
7
|
+
data.tar.gz: 334b17ae6e0e36546cf99617d9a0f4e2bf826bb1db578f4a8c4f556f66edf9585f00fe21b5e69865105e873e50a458e820ede34ddf204883858def40dbdfff4b
|
data/.github/workflows/ruby.yml
CHANGED
@@ -12,12 +12,12 @@ jobs:
|
|
12
12
|
- ubuntu-latest
|
13
13
|
- macos-latest
|
14
14
|
ruby:
|
15
|
-
- 2.
|
16
|
-
-
|
17
|
-
-
|
18
|
-
- 2.
|
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
data/Gemfile
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
}
|
data/ext/digest/crc5/crc5_ext.c
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
}
|
data/ext/digest/crc8/crc8_ext.c
CHANGED
@@ -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
|
-
|
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
data/lib/digest/crc5.rb
CHANGED
@@ -12,26 +12,26 @@ module Digest
|
|
12
12
|
|
13
13
|
XOR_MASK = 0x1f
|
14
14
|
|
15
|
-
CRC_MASK =
|
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,
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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[(
|
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) { '
|
7
|
+
let(:expected) { '01' }
|
8
8
|
|
9
|
-
|
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
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
|
+
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:
|
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.
|
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.
|