digest-crc 0.5.0 → 0.5.1

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: 3d5a255ef5f82e672dc7d0f84078a9b94e7b33a2544224be87264678012bc018
4
- data.tar.gz: 13541d0a4470c110b2dbbf4f6db220df74941941fadb050a2fc2d3f1296abed9
3
+ metadata.gz: 2f92ef55b3e61da5d83aca365fabce146aaa938ff0ee7f380496f30b2909cd8c
4
+ data.tar.gz: a34bfa0d5c6b86e29ee5cc27d157a8ea45596e03ffdd7d7d740eaeb9ccca8e6f
5
5
  SHA512:
6
- metadata.gz: fef49b3b834f178e99d911ed9c7f6fd6c62c1901b2629ffbe57a5054f46286be120c5428c21166f76dd7fca1ee19ceb1649b65bff9401438686bb5636ce1e87f
7
- data.tar.gz: 3eaee048aa5a41b3e1b669575645c538c10ff1faac65f4423c8473d2825198c8718fef3ceff12f91209759ee572b2f5e99d42467cb60d95782fb929fc27048d3
6
+ metadata.gz: cafe8835843afd7873891d6a8c85ba294b8cb846a63641a273844aa50801071d77a92a6e1391e82b9921b199163ab87f9864885ba94f1efaf5a241448a9c0143
7
+ data.tar.gz: 3787c83078142822c4d7ff198abbcd5a148061612079877ed8f4e4a3b828a4addb9484c4eb36beb417f30c570c336e1a708d7d9a3735342b3553f1d18e69fb8a
@@ -1,3 +1,9 @@
1
+ ### 0.5.1 / 2020-03-03
2
+
3
+ * Fixed XOR logic in {Digest::CRC16Genibus}.
4
+ * Freeze all `TABLE` constants.
5
+ * Added missing documentation.
6
+
1
7
  ### 0.5.0 / 2020-03-01
2
8
 
3
9
  * Added {Digest::CRC15}.
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
11
11
  $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
12
12
 
13
13
  require 'digest/crc/version'
14
- Digest::Crc::VERSION
14
+ Digest::CRC::VERSION
15
15
  end
16
16
 
17
17
  gem.summary = gemspec['summary']
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.authors = Array(gemspec['authors'])
21
21
  gem.email = gemspec['email']
22
22
  gem.homepage = gemspec['homepage']
23
+ gem.metadata = gemspec['metadata'] if gemspec['metadata']
23
24
 
24
25
  glob = lambda { |patterns| gem.files & Dir[*patterns] }
25
26
 
@@ -1,5 +1,5 @@
1
1
  name: digest-crc
2
- version: 0.5.0
2
+ version: 0.5.1
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
@@ -9,6 +9,13 @@ license: MIT
9
9
  authors: Postmodern
10
10
  email: postmodern.mod3@gmail.com
11
11
  homepage: https://github.com/postmodern/digest-crc#readme
12
+
13
+ metadata:
14
+ documentation_uri: https://rubydoc.info/gems/digest-crc
15
+ source_code_uri: https://github.com/postmodern/digest-crc
16
+ bug_tracker_uri: https://github.com/postmodern/digest-crc/issues
17
+ changelog_uri: https://github.com/postmodern/digest-crc/blob/master/ChangeLog.md
18
+
12
19
  has_yard: true
13
20
 
14
21
  development_dependencies:
@@ -28,7 +28,7 @@ module Digest
28
28
  0x7c41, 0x39d8, 0x32ea, 0x7773, 0x248e, 0x6117, 0x6a25, 0x2fbc, 0x0846, 0x4ddf, 0x46ed, 0x0374, 0x5089, 0x1510, 0x1e22, 0x5bbb,
29
29
  0x0af8, 0x4f61, 0x4453, 0x01ca, 0x5237, 0x17ae, 0x1c9c, 0x5905, 0x7eff, 0x3b66, 0x3054, 0x75cd, 0x2630, 0x63a9, 0x689b, 0x2d02,
30
30
  0x276f, 0x62f6, 0x69c4, 0x2c5d, 0x7fa0, 0x3a39, 0x310b, 0x7492, 0x5368, 0x16f1, 0x1dc3, 0x585a, 0x0ba7, 0x4e3e, 0x450c, 0x0095
31
- ]
31
+ ].freeze
32
32
 
33
33
  #
34
34
  # Packs the CRC15 checksum.
@@ -8,6 +8,12 @@ module Digest
8
8
  #
9
9
  class CRC16Genibus < CRC16
10
10
 
11
+ INIT_XOR = 0xffff
12
+
13
+ INIT_CRC = 0x0000 ^ INIT_XOR
14
+
15
+ XOR_MASK = 0xffff
16
+
11
17
  # Generated by `./pycrc.py --algorithm=table-driven --model=crc-16 --generate=c`
12
18
  TABLE = [
13
19
  0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
@@ -42,7 +48,7 @@ module Digest
42
48
  0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
43
49
  0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
44
50
  0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
45
- ]
51
+ ].freeze
46
52
 
47
53
  #
48
54
  # Updates the CRC16 Genibus checksum.
@@ -42,7 +42,7 @@ module Digest
42
42
  0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
43
43
  0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
44
44
  0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
45
- ]
45
+ ].freeze
46
46
 
47
47
  #
48
48
  # Updates the CRC16 Kermit checksum.
@@ -12,6 +12,7 @@ module Digest
12
12
 
13
13
  XOR_MASK = 0xffff
14
14
 
15
+ # Generated by `./pycrc.py --algorithm=table-driven --model=x-25 --generate=c`
15
16
  TABLE = [
16
17
  0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
17
18
  0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
@@ -45,7 +46,7 @@ module Digest
45
46
  0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
46
47
  0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
47
48
  0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
48
- ]
49
+ ].freeze
49
50
 
50
51
  end
51
52
  end
@@ -6,6 +6,7 @@ module Digest
6
6
  #
7
7
  class CRC32BZip2 < CRC32
8
8
 
9
+ # Generated by `./pycrc.py --algorithm=table-driven --model=crc-32-bzip2 --generate=c`
9
10
  TABLE = [
10
11
  0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
11
12
  0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
@@ -39,7 +40,7 @@ module Digest
39
40
  0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
40
41
  0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
41
42
  0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
42
- ]
43
+ ].freeze
43
44
 
44
45
  #
45
46
  # Updates the CRC32 BZip2 checksum.
@@ -41,7 +41,7 @@ module Digest
41
41
  0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
42
42
  0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
43
43
  0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
44
- ]
44
+ ].freeze
45
45
 
46
46
  #
47
47
  # Updates the CRC32 POSIX checksum.
@@ -1,12 +1,16 @@
1
1
  require 'digest/crc32'
2
2
 
3
3
  module Digest
4
+ #
5
+ # Implements the CRC32 XFER algorithm.
6
+ #
4
7
  class CRC32XFER < CRC32
5
8
 
6
9
  INIT_CRC = 0x00000000
7
10
 
8
11
  XOR_MASK = 0x00000000
9
12
 
13
+ # Generated by `./pycrc.py --algorithm=table-driven --model=xfer --generate=c`
10
14
  TABLE = [
11
15
  0x00000000, 0x000000af, 0x0000015e, 0x000001f1, 0x000002bc, 0x00000213, 0x000003e2, 0x0000034d,
12
16
  0x00000578, 0x000005d7, 0x00000426, 0x00000489, 0x000007c4, 0x0000076b, 0x0000069a, 0x00000635,
@@ -40,8 +44,14 @@ module Digest
40
44
  0x00006cd8, 0x00006c77, 0x00006d86, 0x00006d29, 0x00006e64, 0x00006ecb, 0x00006f3a, 0x00006f95,
41
45
  0x00006350, 0x000063ff, 0x0000620e, 0x000062a1, 0x000061ec, 0x00006143, 0x000060b2, 0x0000601d,
42
46
  0x00006628, 0x00006687, 0x00006776, 0x000067d9, 0x00006494, 0x0000643b, 0x000065ca, 0x00006565
43
- ]
47
+ ].freeze
44
48
 
49
+ #
50
+ # Updates the CRC32 XFER checksum.
51
+ #
52
+ # @param [String] data
53
+ # The data to update the checksum with.
54
+ #
45
55
  def update(data)
46
56
  data.each_byte do |b|
47
57
  @crc = (@table[((@crc >> 24) ^ b) & 0xff] ^ (@crc << 8)) & 0xffffffff
@@ -78,7 +78,7 @@ module Digest
78
78
  0x0df7adabd7a6e2d6, 0x772fdd63e7936baf, 0xf8474c3bb7cdf024, 0x829f3cf387f8795d,
79
79
  0x66e7a46c27f3aa2c, 0x1c3fd4a417c62355, 0x935745fc4798b8de, 0xe98f353477ad31a7,
80
80
  0xa6df411fbfb21ca3, 0xdc0731d78f8795da, 0x536fa08fdfd90e51, 0x29b7d047efec8728
81
- ]
81
+ ].freeze
82
82
 
83
83
  end
84
84
  end
@@ -80,7 +80,7 @@ module Digest
80
80
  0x50a65c93309e7c0b, 0xe388102d33392364, 0xa4226ac498dedc50, 0x170c267a9b79833f,
81
81
  0xdcd7181e300f9e5e, 0x6ff954a033a8c131, 0x28532e49984f3e05, 0x9b7d62f79be8616a,
82
82
  0xa707db9acf80c06d, 0x14299724cc279f02, 0x5383edcd67c06036, 0xe0ada17364673f59
83
- ]
83
+ ].freeze
84
84
 
85
85
  end
86
86
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
  require 'crc_examples'
3
- require 'digest/crc16_modbus'
3
+ require 'digest/crc16_genibus'
4
4
 
5
- describe Digest::CRC16Modbus do
5
+ describe Digest::CRC16Genibus do
6
6
  let(:string) { '1234567890' }
7
- let(:expected) { 'c20a' }
7
+ let(:expected) { 'cde7' }
8
8
 
9
9
  it_should_behave_like "CRC"
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.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-02 00:00:00.000000000 Z
11
+ date: 2020-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,7 +87,7 @@ files:
87
87
  - spec/crc16_zmodem_spec.rb
88
88
  - spec/crc1_spec.rb
89
89
  - spec/crc24_spec.rb
90
- - spec/crc32_bzip_spec.rb
90
+ - spec/crc32_bzip2_spec.rb
91
91
  - spec/crc32_jam_spec.rb
92
92
  - spec/crc32_mpeg_spec.rb
93
93
  - spec/crc32_posix_spec.rb
@@ -106,7 +106,11 @@ files:
106
106
  homepage: https://github.com/postmodern/digest-crc#readme
107
107
  licenses:
108
108
  - MIT
109
- metadata: {}
109
+ metadata:
110
+ documentation_uri: https://rubydoc.info/gems/digest-crc
111
+ source_code_uri: https://github.com/postmodern/digest-crc
112
+ bug_tracker_uri: https://github.com/postmodern/digest-crc/issues
113
+ changelog_uri: https://github.com/postmodern/digest-crc/blob/master/ChangeLog.md
110
114
  post_install_message:
111
115
  rdoc_options: []
112
116
  require_paths: