digest-crc 0.6.0.rc1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f3a74146b25bc84927e5f441f7a31a23a4465aafeba993d7d9b0b390f81afde
4
- data.tar.gz: d7a9d4dc7e435698dfc8e784464f16c1e2dbf394e93c6889bcaaf00fd3e1887e
3
+ metadata.gz: 1fe46270c7eae650508a5502eebb79a4869fbae54d0fbe839821d10875fb0ecf
4
+ data.tar.gz: 4beab2099969546a407771454e5ded1a5490372418b33b078140f8cac82a2c97
5
5
  SHA512:
6
- metadata.gz: 4ba2b78693fb9af7e7eda4950fcf5d0e46d5c8ed6ad1469d1da444212396a2cf28308e97a055504cf0d04f0f1cfa6f192b2a4414ab9c6328a0d7a285048e5926
7
- data.tar.gz: d04e97f73061f3617bab9d4371fb03463a2b366103ca4e4c8344a9b6d4ccb80e7919c76443cdb311a64a856c951980732e34289bab5fa69b3d3070aa3c8a4130
6
+ metadata.gz: e62799bcab7e38e635d5619beb1ac13c9c4cc5c0017604b5e060672190fc7c5fdc6bfbdc48d164bf191d5906d868f4552a6318930a6fa3d1983cac63acdf8aa5
7
+ data.tar.gz: ff41e5f57d9f9b523105b72f76662b8fac5a1df7485742378bb93ed3e982fb8d69eae14199e7d285e38102d7e3970708b6615919502783f6050278a029666360
@@ -1,4 +1,4 @@
1
- ### 0.6.0 / 2020-06-16
1
+ ### 0.6.0 / 2020-07-01
2
2
 
3
3
  * Implement _optional_ C extensions for all CRC algorithms, resulting in an
4
4
  average performance improvement of ~40x. Note, if for whatever reason the
@@ -6,9 +6,14 @@
6
6
  CRC algorithms will be used instead. If the C extensions were successfully
7
7
  compiled, then they will be loaded and override the pure-Ruby CRC methods with
8
8
  the C equivalents.
9
+ * Alias {Digest::CRC16QT} to {Digest::CRC16X25}, since they are effectively the same (@dearblue).
10
+ * Fix {Digest::CRC32::WIDTH} (@dearblue).
9
11
 
10
- #### Pure Ruby
12
+ #### pure-Ruby (ruby 2.7.1)
11
13
 
14
+ Loading Digest::CRC classes ...
15
+ Generating 1000 8Kb lengthed strings ...
16
+ Benchmarking Digest::CRC classes ...
12
17
  user system total real
13
18
  Digest::CRC1#update 0.412953 0.000000 0.412953 ( 0.414688)
14
19
  Digest::CRC5#update 1.116375 0.000003 1.116378 ( 1.120741)
@@ -37,8 +42,45 @@
37
42
  Digest::CRC64Jones#update 2.678003 0.000000 2.678003 ( 2.691390)
38
43
  Digest::CRC64XZ#update 2.671395 0.000000 2.671395 ( 2.682684)
39
44
 
40
- #### C extensions
45
+ #### pure-Ruby (jruby 9.2.11.1)
41
46
 
47
+ Loading Digest::CRC classes ...
48
+ Generating 1000 8Kb lengthed strings ...
49
+ Benchmarking Digest::CRC classes ...
50
+ user system total real
51
+ Digest::CRC1#update 0.700000 0.070000 0.770000 ( 0.436112)
52
+ Digest::CRC5#update 1.930000 0.050000 1.980000 ( 1.084749)
53
+ Digest::CRC8#update 1.510000 0.060000 1.570000 ( 0.979123)
54
+ Digest::CRC8_1Wire#update 0.730000 0.030000 0.760000 ( 0.761309)
55
+ Digest::CRC15#update 1.760000 0.080000 1.840000 ( 1.061413)
56
+ Digest::CRC16#update 1.560000 0.030000 1.590000 ( 0.951273)
57
+ Digest::CRC16CCITT#update 1.700000 0.010000 1.710000 ( 1.046854)
58
+ Digest::CRC16DNP#update 1.490000 0.000000 1.490000 ( 0.902434)
59
+ Digest::CRC16Genibus#update 1.820000 0.020000 1.840000 ( 1.030269)
60
+ Digest::CRC16Modbus#update 0.740000 0.010000 0.750000 ( 0.738604)
61
+ Digest::CRC16QT#update 7.280000 0.040000 7.320000 ( 6.399987)
62
+ Digest::CRC16USB#update 0.930000 0.000000 0.930000 ( 0.801541)
63
+ Digest::CRC16X25#update 0.870000 0.000000 0.870000 ( 0.805130)
64
+ Digest::CRC16XModem#update 1.320000 0.010000 1.330000 ( 0.968956)
65
+ Digest::CRC16ZModem#update 1.300000 0.010000 1.310000 ( 0.928303)
66
+ Digest::CRC24#update 1.550000 0.020000 1.570000 ( 1.024450)
67
+ Digest::CRC32#update 1.260000 0.000000 1.260000 ( 0.913814)
68
+ Digest::CRC32BZip2#update 1.210000 0.010000 1.220000 ( 0.919086)
69
+ Digest::CRC32c#update 0.770000 0.010000 0.780000 ( 0.761726)
70
+ Digest::CRC32Jam#update 0.930000 0.000000 0.930000 ( 0.800468)
71
+ Digest::CRC32MPEG#update 1.240000 0.010000 1.250000 ( 0.933962)
72
+ Digest::CRC32POSIX#update 1.290000 0.010000 1.300000 ( 0.925254)
73
+ Digest::CRC32XFER#update 1.270000 0.000000 1.270000 ( 0.920521)
74
+ Digest::CRC64#update 3.480000 0.020000 3.500000 ( 2.883794)
75
+ Digest::CRC64Jones#update 2.740000 0.000000 2.740000 ( 2.738251)
76
+ Digest::CRC64XZ#update 2.780000 0.010000 2.790000 ( 2.715833)
77
+
78
+
79
+ #### C extensions (ruby 2.7.1)
80
+
81
+ Loading Digest::CRC classes ...
82
+ Generating 1000 8Kb lengthed strings ...
83
+ Benchmarking Digest::CRC classes ...
42
84
  user system total real
43
85
  Digest::CRC1#update 0.407438 0.000000 0.407438 ( 0.410495)
44
86
  Digest::CRC5#update 0.022873 0.000000 0.022873 ( 0.023796)
@@ -1,5 +1,5 @@
1
1
  name: digest-crc
2
- version: 0.6.0.rc1
2
+ version: 0.6.0
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
@@ -1,67 +1,10 @@
1
- require 'digest/crc16_ccitt'
1
+ require 'digest/crc16_x_25'
2
2
 
3
3
  module Digest
4
4
  #
5
5
  # Implements the CRC16_CCITT algorithm used in QT algorithms.
6
6
  #
7
- # @author Matthew Bednarski
7
+ # @note Is exactly the same as the CRC16 X-25 algorithm.
8
8
  #
9
- class CRC16QT < CRC16CCITT
10
-
11
- FINAL_XOR = 0xffff
12
-
13
- #
14
- # Updates the CRC16 checksum.
15
- #
16
- # @param [String] data
17
- # The data to update the checksum with.
18
- #
19
- def update(data)
20
- data.each_byte do |b|
21
- b = revert_byte(b)
22
- @crc = ((@table[((@crc >> 8) ^ b) & 0xff] ^ (@crc << 8)) & 0xffff)
23
- end
24
-
25
- return self
26
- end
27
-
28
- #
29
- # Calculates the CRC checksum value.
30
- #
31
- # @return [Integer]
32
- #
33
- def checksum
34
- crc = super
35
- crc ^= FINAL_XOR
36
- crc = revert_bits(crc)
37
- return crc
38
- end
39
-
40
- protected
41
-
42
- def revert_bits(cc)
43
- ob = 0
44
- b = (1 << 15)
45
-
46
- 16.times do |t|
47
- ob |= (1 << t) if (cc & b) != 0
48
- b >>= 1
49
- end
50
-
51
- return ob
52
- end
53
-
54
- def revert_byte(cc)
55
- ob = 0
56
- b = (1 << 7)
57
-
58
- 8.times do |t|
59
- ob |= (1 << t) if (cc & b) != 0
60
- b >>= 1
61
- end
62
-
63
- return ob
64
- end
65
-
66
- end
9
+ CRC16QT = CRC16X25
67
10
  end
@@ -6,7 +6,7 @@ module Digest
6
6
  #
7
7
  class CRC32 < CRC
8
8
 
9
- WIDTH = 4
9
+ WIDTH = 32
10
10
 
11
11
  INIT_CRC = 0xffffffff
12
12
 
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
- require 'crc_examples'
3
2
  require 'digest/crc16_qt'
4
3
 
5
- describe Digest::CRC16QT do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '4b13' }
4
+ describe "Digest::CRC16QT" do
5
+ subject { Digest::CRC16QT }
8
6
 
9
- it_should_behave_like "CRC"
7
+ it "should be an alias to Digest::CRC16X25" do
8
+ expect(subject).to be(Digest::CRC16X25)
9
+ end
10
10
  end
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.0.rc1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-16 00:00:00.000000000 Z
11
+ date: 2020-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
234
  - !ruby/object:Gem::Version
235
235
  version: '0'
236
236
  requirements: []
237
- rubygems_version: 3.0.3
237
+ rubygems_version: 3.1.2
238
238
  signing_key:
239
239
  specification_version: 4
240
240
  summary: A Cyclic Redundancy Check (CRC) library for Ruby.