digest-crc 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +0 -1
- data/ChangeLog.md +15 -0
- data/Gemfile +2 -1
- data/README.md +12 -2
- data/Rakefile +1 -2
- data/benchmarks.rb +26 -17
- data/gemspec.yml +2 -2
- data/lib/digest/crc15.rb +66 -0
- data/lib/digest/crc16_genibus.rb +62 -0
- data/lib/digest/crc16_kermit.rb +62 -0
- data/lib/digest/crc16_x_25.rb +51 -0
- data/lib/digest/crc32_bzip2.rb +59 -0
- data/lib/digest/crc32_jam.rb +16 -0
- data/lib/digest/crc32_mpeg.rb +4 -1
- data/lib/digest/crc32_posix.rb +61 -0
- data/lib/digest/crc32_xfer.rb +54 -0
- data/lib/digest/crc64_jones.rb +84 -0
- data/lib/digest/crc64_xz.rb +86 -0
- data/lib/digest/crc8_1wire.rb +4 -1
- data/spec/crc15_spec.rb +10 -0
- data/spec/crc16_genibus_spec.rb +10 -0
- data/spec/crc16_kermit_spec.rb +10 -0
- data/spec/crc16_x_25_spec.rb +10 -0
- data/spec/crc32_bzip_spec.rb +10 -0
- data/spec/crc32_jam_spec.rb +10 -0
- data/spec/crc32_mpeg_spec.rb +7 -1
- data/spec/crc32_posix_spec.rb +10 -0
- data/spec/crc32_xfer_spec.rb +10 -0
- data/spec/crc64_jones_spec.rb +10 -0
- data/spec/crc64_xz_spec.rb +10 -0
- data/spec/crc8_1wire_spec.rb +7 -1
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d5a255ef5f82e672dc7d0f84078a9b94e7b33a2544224be87264678012bc018
|
4
|
+
data.tar.gz: 13541d0a4470c110b2dbbf4f6db220df74941941fadb050a2fc2d3f1296abed9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fef49b3b834f178e99d911ed9c7f6fd6c62c1901b2629ffbe57a5054f46286be120c5428c21166f76dd7fca1ee19ceb1649b65bff9401438686bb5636ce1e87f
|
7
|
+
data.tar.gz: 3eaee048aa5a41b3e1b669575645c538c10ff1faac65f4423c8473d2825198c8718fef3ceff12f91209759ee572b2f5e99d42467cb60d95782fb929fc27048d3
|
data/.yardopts
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
### 0.5.0 / 2020-03-01
|
2
|
+
|
3
|
+
* Added {Digest::CRC15}.
|
4
|
+
* Added {Digest::CRC16Genibus}.
|
5
|
+
* Added {Digest::CRC16Kermit}.
|
6
|
+
* Added {Digest::CRC16X25}.
|
7
|
+
* Added {Digest::CRC32BZip2}.
|
8
|
+
* Added {Digest::CRC32Jam}.
|
9
|
+
* Added {Digest::CRC32POSIX}.
|
10
|
+
* Added {Digest::CRC32XFER}.
|
11
|
+
* Added {Digest::CRC64Jones}.
|
12
|
+
* Added {Digest::CRC64XZ}.
|
13
|
+
* Renamed `Digest::CRC32Mpeg` to {Digest::CRC32MPEG}.
|
14
|
+
* Renamed `Digest::CRC81Wire` to {Digest::CRC8_1Wire}.
|
15
|
+
|
1
16
|
### 0.4.2 / 2020-03-01
|
2
17
|
|
3
18
|
* Corrected the logic in {Digest::CRC32#update}.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -18,20 +18,30 @@ module.
|
|
18
18
|
* {Digest::CRC1 CRC1}
|
19
19
|
* {Digest::CRC5 CRC5}
|
20
20
|
* {Digest::CRC8 CRC8}
|
21
|
-
* {Digest::
|
21
|
+
* {Digest::CRC8_1Wire CRC8 1-Wire}
|
22
|
+
* {Digest::CRC15 CRC15}
|
22
23
|
* {Digest::CRC16 CRC16}
|
23
24
|
* {Digest::CRC16CCITT CRC16 CCITT}
|
24
25
|
* {Digest::CRC16DNP CRC16 DNP}
|
26
|
+
* {Digest::CRC16Genibus CRC16 Genibus}
|
27
|
+
* {Digest::CRC16Kermit CRC16 Kermit}
|
25
28
|
* {Digest::CRC16Modbus CRC16 Modbus}
|
26
29
|
* {Digest::CRC16USB CRC16 USB}
|
30
|
+
* {Digest::CRC16X25 CRC16 X25}
|
27
31
|
* {Digest::CRC16XModem CRC16 XModem}
|
28
32
|
* {Digest::CRC16ZModem CRC16 ZModem}
|
29
33
|
* {Digest::CRC16QT CRC16 QT}
|
30
34
|
* {Digest::CRC24 CRC24}
|
31
35
|
* {Digest::CRC32 CRC32}
|
36
|
+
* {Digest::CRC32BZip2 CRC32 BZip2}
|
32
37
|
* {Digest::CRC32c CRC32c}
|
33
|
-
* {Digest::
|
38
|
+
* {Digest::CRC32Jam CRC32 Jam}
|
39
|
+
* {Digest::CRC32MPEG CRC32 MPEG}
|
40
|
+
* {Digest::CRC32POSIX CRC32 POSIX}
|
41
|
+
* {Digest::CRC32XFER CRC32 XFER}
|
34
42
|
* {Digest::CRC64 CRC64}
|
43
|
+
* {Digest::CRC64Jones CRC64 Jones}
|
44
|
+
* {Digest::CRC64XZ CRC64 XZ}
|
35
45
|
* Pure Ruby implementation.
|
36
46
|
* Provides CRC Tables for optimized calculations.
|
37
47
|
|
data/Rakefile
CHANGED
data/benchmarks.rb
CHANGED
@@ -3,23 +3,32 @@ require 'benchmark'
|
|
3
3
|
$LOAD_PATH.unshift(File.expand_path('lib'))
|
4
4
|
|
5
5
|
CRCs = {
|
6
|
-
'crc1'
|
7
|
-
'crc5'
|
8
|
-
'crc8'
|
9
|
-
'crc8_1wire'
|
10
|
-
'
|
11
|
-
'
|
12
|
-
'
|
13
|
-
'
|
14
|
-
'
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
6
|
+
'crc1' => 'CRC1',
|
7
|
+
'crc5' => 'CRC5',
|
8
|
+
'crc8' => 'CRC8',
|
9
|
+
'crc8_1wire' => 'CRC81Wire',
|
10
|
+
'crc15' => 'CRC15',
|
11
|
+
'crc16' => 'CRC16',
|
12
|
+
'crc16_ccitt' => 'CRC16CCITT',
|
13
|
+
'crc16_dnp' => 'CRC16DNP',
|
14
|
+
'crc16_genibus' => 'CRC16Genibus',
|
15
|
+
'crc16_modbus' => 'CRC16Modbus',
|
16
|
+
'crc16_qt' => 'CRC16QT',
|
17
|
+
'crc16_usb' => 'CRC16USB',
|
18
|
+
'crc16_x_25' => 'CRC16X25',
|
19
|
+
'crc16_xmodem' => 'CRC16XModem',
|
20
|
+
'crc16_zmodem' => 'CRC16ZModem',
|
21
|
+
'crc24' => 'CRC24',
|
22
|
+
'crc32' => 'CRC32',
|
23
|
+
'crc32_bzip2' => 'CRC32BZip2',
|
24
|
+
'crc32c' => 'CRC32c',
|
25
|
+
'crc32_jam' => 'CRC32Jam',
|
26
|
+
'crc32_mpeg' => 'CRC32Mpeg',
|
27
|
+
'crc32_posix' => 'CRC32POSIX',
|
28
|
+
'crc32_xfer' => 'CRC32XFER',
|
29
|
+
'crc64' => 'CRC64',
|
30
|
+
'crc64_jones' => 'CRC64Jones',
|
31
|
+
'crc64_xz' => 'CRC64XZ',
|
23
32
|
}
|
24
33
|
|
25
34
|
puts "Loading Digest::CRC classes ..."
|
data/gemspec.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
name: digest-crc
|
2
|
-
version: 0.
|
2
|
+
version: 0.5.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
|
@@ -12,4 +12,4 @@ homepage: https://github.com/postmodern/digest-crc#readme
|
|
12
12
|
has_yard: true
|
13
13
|
|
14
14
|
development_dependencies:
|
15
|
-
bundler: ~>
|
15
|
+
bundler: ~> 2.0
|
data/lib/digest/crc15.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'digest/crc'
|
2
|
+
|
3
|
+
module Digest
|
4
|
+
#
|
5
|
+
# Implements the CRC15 algorithm.
|
6
|
+
#
|
7
|
+
# @since 0.5.0
|
8
|
+
#
|
9
|
+
class CRC15 < CRC
|
10
|
+
|
11
|
+
WIDTH = 15
|
12
|
+
|
13
|
+
# Generated by `./pycrc.py --algorithm=table-driven --model=crc-16 --generate=c`
|
14
|
+
TABLE = [
|
15
|
+
0x0000, 0x4599, 0x4eab, 0x0b32, 0x58cf, 0x1d56, 0x1664, 0x53fd, 0x7407, 0x319e, 0x3aac, 0x7f35, 0x2cc8, 0x6951, 0x6263, 0x27fa,
|
16
|
+
0x2d97, 0x680e, 0x633c, 0x26a5, 0x7558, 0x30c1, 0x3bf3, 0x7e6a, 0x5990, 0x1c09, 0x173b, 0x52a2, 0x015f, 0x44c6, 0x4ff4, 0x0a6d,
|
17
|
+
0x5b2e, 0x1eb7, 0x1585, 0x501c, 0x03e1, 0x4678, 0x4d4a, 0x08d3, 0x2f29, 0x6ab0, 0x6182, 0x241b, 0x77e6, 0x327f, 0x394d, 0x7cd4,
|
18
|
+
0x76b9, 0x3320, 0x3812, 0x7d8b, 0x2e76, 0x6bef, 0x60dd, 0x2544, 0x02be, 0x4727, 0x4c15, 0x098c, 0x5a71, 0x1fe8, 0x14da, 0x5143,
|
19
|
+
0x73c5, 0x365c, 0x3d6e, 0x78f7, 0x2b0a, 0x6e93, 0x65a1, 0x2038, 0x07c2, 0x425b, 0x4969, 0x0cf0, 0x5f0d, 0x1a94, 0x11a6, 0x543f,
|
20
|
+
0x5e52, 0x1bcb, 0x10f9, 0x5560, 0x069d, 0x4304, 0x4836, 0x0daf, 0x2a55, 0x6fcc, 0x64fe, 0x2167, 0x729a, 0x3703, 0x3c31, 0x79a8,
|
21
|
+
0x28eb, 0x6d72, 0x6640, 0x23d9, 0x7024, 0x35bd, 0x3e8f, 0x7b16, 0x5cec, 0x1975, 0x1247, 0x57de, 0x0423, 0x41ba, 0x4a88, 0x0f11,
|
22
|
+
0x057c, 0x40e5, 0x4bd7, 0x0e4e, 0x5db3, 0x182a, 0x1318, 0x5681, 0x717b, 0x34e2, 0x3fd0, 0x7a49, 0x29b4, 0x6c2d, 0x671f, 0x2286,
|
23
|
+
0x2213, 0x678a, 0x6cb8, 0x2921, 0x7adc, 0x3f45, 0x3477, 0x71ee, 0x5614, 0x138d, 0x18bf, 0x5d26, 0x0edb, 0x4b42, 0x4070, 0x05e9,
|
24
|
+
0x0f84, 0x4a1d, 0x412f, 0x04b6, 0x574b, 0x12d2, 0x19e0, 0x5c79, 0x7b83, 0x3e1a, 0x3528, 0x70b1, 0x234c, 0x66d5, 0x6de7, 0x287e,
|
25
|
+
0x793d, 0x3ca4, 0x3796, 0x720f, 0x21f2, 0x646b, 0x6f59, 0x2ac0, 0x0d3a, 0x48a3, 0x4391, 0x0608, 0x55f5, 0x106c, 0x1b5e, 0x5ec7,
|
26
|
+
0x54aa, 0x1133, 0x1a01, 0x5f98, 0x0c65, 0x49fc, 0x42ce, 0x0757, 0x20ad, 0x6534, 0x6e06, 0x2b9f, 0x7862, 0x3dfb, 0x36c9, 0x7350,
|
27
|
+
0x51d6, 0x144f, 0x1f7d, 0x5ae4, 0x0919, 0x4c80, 0x47b2, 0x022b, 0x25d1, 0x6048, 0x6b7a, 0x2ee3, 0x7d1e, 0x3887, 0x33b5, 0x762c,
|
28
|
+
0x7c41, 0x39d8, 0x32ea, 0x7773, 0x248e, 0x6117, 0x6a25, 0x2fbc, 0x0846, 0x4ddf, 0x46ed, 0x0374, 0x5089, 0x1510, 0x1e22, 0x5bbb,
|
29
|
+
0x0af8, 0x4f61, 0x4453, 0x01ca, 0x5237, 0x17ae, 0x1c9c, 0x5905, 0x7eff, 0x3b66, 0x3054, 0x75cd, 0x2630, 0x63a9, 0x689b, 0x2d02,
|
30
|
+
0x276f, 0x62f6, 0x69c4, 0x2c5d, 0x7fa0, 0x3a39, 0x310b, 0x7492, 0x5368, 0x16f1, 0x1dc3, 0x585a, 0x0ba7, 0x4e3e, 0x450c, 0x0095
|
31
|
+
]
|
32
|
+
|
33
|
+
#
|
34
|
+
# Packs the CRC15 checksum.
|
35
|
+
#
|
36
|
+
# @param [Integer] crc
|
37
|
+
# The CRC15 checksum to pack.
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
# The packed CRC15 checksum.
|
41
|
+
#
|
42
|
+
def self.pack(crc)
|
43
|
+
buffer = ''
|
44
|
+
|
45
|
+
buffer << ((crc & 0x7f00) >> 8).chr
|
46
|
+
buffer << (crc & 0xff).chr
|
47
|
+
|
48
|
+
buffer
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# Updates the CRC15 checksum.
|
53
|
+
#
|
54
|
+
# @param [String] data
|
55
|
+
# The data to update the checksum with.
|
56
|
+
#
|
57
|
+
def update(data)
|
58
|
+
data.each_byte do |b|
|
59
|
+
@crc = (@table[((@crc >> 7) ^ b) & 0xff] ^ (@crc << 8)) & 0x7fff
|
60
|
+
end
|
61
|
+
|
62
|
+
return self
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'digest/crc16'
|
2
|
+
|
3
|
+
module Digest
|
4
|
+
#
|
5
|
+
# Implements the CRC16 Genibus algorithm.
|
6
|
+
#
|
7
|
+
# @since 0.5.0
|
8
|
+
#
|
9
|
+
class CRC16Genibus < CRC16
|
10
|
+
|
11
|
+
# Generated by `./pycrc.py --algorithm=table-driven --model=crc-16 --generate=c`
|
12
|
+
TABLE = [
|
13
|
+
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
14
|
+
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
15
|
+
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
16
|
+
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
|
17
|
+
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
|
18
|
+
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
|
19
|
+
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
|
20
|
+
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
|
21
|
+
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
|
22
|
+
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
|
23
|
+
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
|
24
|
+
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
|
25
|
+
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
|
26
|
+
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
|
27
|
+
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
|
28
|
+
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
|
29
|
+
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
|
30
|
+
0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
|
31
|
+
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
|
32
|
+
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
|
33
|
+
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
|
34
|
+
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
35
|
+
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
|
36
|
+
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
|
37
|
+
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
|
38
|
+
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
|
39
|
+
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
|
40
|
+
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
|
41
|
+
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
|
42
|
+
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
|
43
|
+
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
|
44
|
+
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
|
45
|
+
]
|
46
|
+
|
47
|
+
#
|
48
|
+
# Updates the CRC16 Genibus checksum.
|
49
|
+
#
|
50
|
+
# @param [String] data
|
51
|
+
# The data to update the checksum with.
|
52
|
+
#
|
53
|
+
def update(data)
|
54
|
+
data.each_byte do |b|
|
55
|
+
@crc = (@table[((@crc >> 8) ^ b) & 0xff] ^ (@crc << 8)) & 0xffff
|
56
|
+
end
|
57
|
+
|
58
|
+
return self
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "digest/crc16"
|
2
|
+
|
3
|
+
module Digest
|
4
|
+
#
|
5
|
+
# Implements Kermit's CRC16 function.
|
6
|
+
#
|
7
|
+
# @since 0.5.0
|
8
|
+
#
|
9
|
+
class CRC16Kermit < CRC16
|
10
|
+
|
11
|
+
# Generated by `./pycrc.py --algorithm=table-driven --model=kermit --generate=c`
|
12
|
+
TABLE = [
|
13
|
+
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
14
|
+
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
15
|
+
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
16
|
+
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
17
|
+
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
|
18
|
+
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
|
19
|
+
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
20
|
+
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
|
21
|
+
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
|
22
|
+
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
|
23
|
+
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
|
24
|
+
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
|
25
|
+
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
|
26
|
+
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
27
|
+
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
|
28
|
+
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
|
29
|
+
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
|
30
|
+
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
31
|
+
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
|
32
|
+
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
|
33
|
+
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
34
|
+
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
35
|
+
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
|
36
|
+
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
|
37
|
+
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
|
38
|
+
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
|
39
|
+
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
40
|
+
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
41
|
+
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
|
42
|
+
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
43
|
+
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
44
|
+
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
45
|
+
]
|
46
|
+
|
47
|
+
#
|
48
|
+
# Updates the CRC16 Kermit checksum.
|
49
|
+
#
|
50
|
+
# @param [String] data
|
51
|
+
# The data to update the checksum with.
|
52
|
+
#
|
53
|
+
def update(data)
|
54
|
+
data.each_byte do |b|
|
55
|
+
@crc = (@table[(@crc ^ b) & 0xff] ^ (@crc >> 8)) & 0xffff
|
56
|
+
end
|
57
|
+
|
58
|
+
return self
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'digest/crc16'
|
2
|
+
|
3
|
+
module Digest
|
4
|
+
#
|
5
|
+
# Implements the CRC16 X25 algorithm.
|
6
|
+
#
|
7
|
+
class CRC16X25 < CRC16
|
8
|
+
|
9
|
+
INIT_XOR = 0xffff
|
10
|
+
|
11
|
+
INIT_CRC = 0x0 ^ INIT_XOR
|
12
|
+
|
13
|
+
XOR_MASK = 0xffff
|
14
|
+
|
15
|
+
TABLE = [
|
16
|
+
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
17
|
+
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
18
|
+
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
19
|
+
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
20
|
+
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
|
21
|
+
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
|
22
|
+
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
23
|
+
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
|
24
|
+
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
|
25
|
+
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
|
26
|
+
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
|
27
|
+
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
|
28
|
+
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
|
29
|
+
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
30
|
+
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
|
31
|
+
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
|
32
|
+
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
|
33
|
+
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
34
|
+
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
|
35
|
+
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
|
36
|
+
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
37
|
+
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
38
|
+
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
|
39
|
+
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
|
40
|
+
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
|
41
|
+
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
|
42
|
+
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
43
|
+
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
44
|
+
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
|
45
|
+
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
46
|
+
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
47
|
+
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
48
|
+
]
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'digest/crc32'
|
2
|
+
|
3
|
+
module Digest
|
4
|
+
#
|
5
|
+
# Implements the CRC32 BZip2 algorithm
|
6
|
+
#
|
7
|
+
class CRC32BZip2 < CRC32
|
8
|
+
|
9
|
+
TABLE = [
|
10
|
+
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
|
11
|
+
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
|
12
|
+
0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
|
13
|
+
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd,
|
14
|
+
0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
|
15
|
+
0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
|
16
|
+
0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
|
17
|
+
0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d,
|
18
|
+
0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
|
19
|
+
0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca,
|
20
|
+
0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02,
|
21
|
+
0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
|
22
|
+
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692,
|
23
|
+
0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
|
24
|
+
0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
|
25
|
+
0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a,
|
26
|
+
0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
|
27
|
+
0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
|
28
|
+
0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
|
29
|
+
0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
|
30
|
+
0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
|
31
|
+
0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
|
32
|
+
0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
|
33
|
+
0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
|
34
|
+
0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
|
35
|
+
0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
|
36
|
+
0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
|
37
|
+
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
|
38
|
+
0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
|
39
|
+
0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
|
40
|
+
0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
|
41
|
+
0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
|
42
|
+
]
|
43
|
+
|
44
|
+
#
|
45
|
+
# Updates the CRC32 BZip2 checksum.
|
46
|
+
#
|
47
|
+
# @param [String] data
|
48
|
+
# The data to update the checksum with.
|
49
|
+
#
|
50
|
+
def update(data)
|
51
|
+
data.each_byte do |b|
|
52
|
+
@crc = (@table[((@crc >> 24) ^ b) & 0xff] ^ (@crc << 8)) & 0xffffffff
|
53
|
+
end
|
54
|
+
|
55
|
+
return self
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
data/lib/digest/crc32_mpeg.rb
CHANGED
@@ -4,7 +4,7 @@ module Digest
|
|
4
4
|
#
|
5
5
|
# Implements the CRC32 Mpeg algorithm.
|
6
6
|
#
|
7
|
-
class
|
7
|
+
class CRC32MPEG < CRC32
|
8
8
|
|
9
9
|
XOR_MASK = 0x00000000
|
10
10
|
|
@@ -91,4 +91,7 @@ module Digest
|
|
91
91
|
end
|
92
92
|
|
93
93
|
end
|
94
|
+
|
95
|
+
# @deprecated Please use {CRC32MPEG}.
|
96
|
+
CRC32Mpeg = CRC32MPEG
|
94
97
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'digest/crc32'
|
2
|
+
|
3
|
+
module Digest
|
4
|
+
#
|
5
|
+
# Implements the CRC32 POSIX algorithm.
|
6
|
+
#
|
7
|
+
class CRC32POSIX < CRC32
|
8
|
+
|
9
|
+
INIT_CRC = 0x00000000
|
10
|
+
|
11
|
+
TABLE = [
|
12
|
+
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
|
13
|
+
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
|
14
|
+
0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
|
15
|
+
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd,
|
16
|
+
0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
|
17
|
+
0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
|
18
|
+
0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
|
19
|
+
0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d,
|
20
|
+
0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
|
21
|
+
0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca,
|
22
|
+
0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02,
|
23
|
+
0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
|
24
|
+
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692,
|
25
|
+
0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
|
26
|
+
0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
|
27
|
+
0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a,
|
28
|
+
0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
|
29
|
+
0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
|
30
|
+
0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
|
31
|
+
0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
|
32
|
+
0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
|
33
|
+
0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
|
34
|
+
0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
|
35
|
+
0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
|
36
|
+
0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
|
37
|
+
0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
|
38
|
+
0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
|
39
|
+
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
|
40
|
+
0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
|
41
|
+
0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
|
42
|
+
0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
|
43
|
+
0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
|
44
|
+
]
|
45
|
+
|
46
|
+
#
|
47
|
+
# Updates the CRC32 POSIX 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 >> 24) ^ b) & 0xff] ^ (@crc << 8)) & 0xffffffff
|
55
|
+
end
|
56
|
+
|
57
|
+
return self
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'digest/crc32'
|
2
|
+
|
3
|
+
module Digest
|
4
|
+
class CRC32XFER < CRC32
|
5
|
+
|
6
|
+
INIT_CRC = 0x00000000
|
7
|
+
|
8
|
+
XOR_MASK = 0x00000000
|
9
|
+
|
10
|
+
TABLE = [
|
11
|
+
0x00000000, 0x000000af, 0x0000015e, 0x000001f1, 0x000002bc, 0x00000213, 0x000003e2, 0x0000034d,
|
12
|
+
0x00000578, 0x000005d7, 0x00000426, 0x00000489, 0x000007c4, 0x0000076b, 0x0000069a, 0x00000635,
|
13
|
+
0x00000af0, 0x00000a5f, 0x00000bae, 0x00000b01, 0x0000084c, 0x000008e3, 0x00000912, 0x000009bd,
|
14
|
+
0x00000f88, 0x00000f27, 0x00000ed6, 0x00000e79, 0x00000d34, 0x00000d9b, 0x00000c6a, 0x00000cc5,
|
15
|
+
0x000015e0, 0x0000154f, 0x000014be, 0x00001411, 0x0000175c, 0x000017f3, 0x00001602, 0x000016ad,
|
16
|
+
0x00001098, 0x00001037, 0x000011c6, 0x00001169, 0x00001224, 0x0000128b, 0x0000137a, 0x000013d5,
|
17
|
+
0x00001f10, 0x00001fbf, 0x00001e4e, 0x00001ee1, 0x00001dac, 0x00001d03, 0x00001cf2, 0x00001c5d,
|
18
|
+
0x00001a68, 0x00001ac7, 0x00001b36, 0x00001b99, 0x000018d4, 0x0000187b, 0x0000198a, 0x00001925,
|
19
|
+
0x00002bc0, 0x00002b6f, 0x00002a9e, 0x00002a31, 0x0000297c, 0x000029d3, 0x00002822, 0x0000288d,
|
20
|
+
0x00002eb8, 0x00002e17, 0x00002fe6, 0x00002f49, 0x00002c04, 0x00002cab, 0x00002d5a, 0x00002df5,
|
21
|
+
0x00002130, 0x0000219f, 0x0000206e, 0x000020c1, 0x0000238c, 0x00002323, 0x000022d2, 0x0000227d,
|
22
|
+
0x00002448, 0x000024e7, 0x00002516, 0x000025b9, 0x000026f4, 0x0000265b, 0x000027aa, 0x00002705,
|
23
|
+
0x00003e20, 0x00003e8f, 0x00003f7e, 0x00003fd1, 0x00003c9c, 0x00003c33, 0x00003dc2, 0x00003d6d,
|
24
|
+
0x00003b58, 0x00003bf7, 0x00003a06, 0x00003aa9, 0x000039e4, 0x0000394b, 0x000038ba, 0x00003815,
|
25
|
+
0x000034d0, 0x0000347f, 0x0000358e, 0x00003521, 0x0000366c, 0x000036c3, 0x00003732, 0x0000379d,
|
26
|
+
0x000031a8, 0x00003107, 0x000030f6, 0x00003059, 0x00003314, 0x000033bb, 0x0000324a, 0x000032e5,
|
27
|
+
0x00005780, 0x0000572f, 0x000056de, 0x00005671, 0x0000553c, 0x00005593, 0x00005462, 0x000054cd,
|
28
|
+
0x000052f8, 0x00005257, 0x000053a6, 0x00005309, 0x00005044, 0x000050eb, 0x0000511a, 0x000051b5,
|
29
|
+
0x00005d70, 0x00005ddf, 0x00005c2e, 0x00005c81, 0x00005fcc, 0x00005f63, 0x00005e92, 0x00005e3d,
|
30
|
+
0x00005808, 0x000058a7, 0x00005956, 0x000059f9, 0x00005ab4, 0x00005a1b, 0x00005bea, 0x00005b45,
|
31
|
+
0x00004260, 0x000042cf, 0x0000433e, 0x00004391, 0x000040dc, 0x00004073, 0x00004182, 0x0000412d,
|
32
|
+
0x00004718, 0x000047b7, 0x00004646, 0x000046e9, 0x000045a4, 0x0000450b, 0x000044fa, 0x00004455,
|
33
|
+
0x00004890, 0x0000483f, 0x000049ce, 0x00004961, 0x00004a2c, 0x00004a83, 0x00004b72, 0x00004bdd,
|
34
|
+
0x00004de8, 0x00004d47, 0x00004cb6, 0x00004c19, 0x00004f54, 0x00004ffb, 0x00004e0a, 0x00004ea5,
|
35
|
+
0x00007c40, 0x00007cef, 0x00007d1e, 0x00007db1, 0x00007efc, 0x00007e53, 0x00007fa2, 0x00007f0d,
|
36
|
+
0x00007938, 0x00007997, 0x00007866, 0x000078c9, 0x00007b84, 0x00007b2b, 0x00007ada, 0x00007a75,
|
37
|
+
0x000076b0, 0x0000761f, 0x000077ee, 0x00007741, 0x0000740c, 0x000074a3, 0x00007552, 0x000075fd,
|
38
|
+
0x000073c8, 0x00007367, 0x00007296, 0x00007239, 0x00007174, 0x000071db, 0x0000702a, 0x00007085,
|
39
|
+
0x000069a0, 0x0000690f, 0x000068fe, 0x00006851, 0x00006b1c, 0x00006bb3, 0x00006a42, 0x00006aed,
|
40
|
+
0x00006cd8, 0x00006c77, 0x00006d86, 0x00006d29, 0x00006e64, 0x00006ecb, 0x00006f3a, 0x00006f95,
|
41
|
+
0x00006350, 0x000063ff, 0x0000620e, 0x000062a1, 0x000061ec, 0x00006143, 0x000060b2, 0x0000601d,
|
42
|
+
0x00006628, 0x00006687, 0x00006776, 0x000067d9, 0x00006494, 0x0000643b, 0x000065ca, 0x00006565
|
43
|
+
]
|
44
|
+
|
45
|
+
def update(data)
|
46
|
+
data.each_byte do |b|
|
47
|
+
@crc = (@table[((@crc >> 24) ^ b) & 0xff] ^ (@crc << 8)) & 0xffffffff
|
48
|
+
end
|
49
|
+
|
50
|
+
return self
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'digest/crc64'
|
2
|
+
|
3
|
+
module Digest
|
4
|
+
#
|
5
|
+
# Implements the CRC64 Jones algorithm.
|
6
|
+
#
|
7
|
+
# @since 0.5.0
|
8
|
+
#
|
9
|
+
class CRC64Jones < CRC64
|
10
|
+
|
11
|
+
INIT_XOR = 0xffffffffffffffff
|
12
|
+
|
13
|
+
INIT_CRC = 0x0 ^ INIT_XOR
|
14
|
+
|
15
|
+
# Generated by `./pycrc.py --algorithm=table-driven --model=crc-64-jones --generate=c`
|
16
|
+
TABLE = [
|
17
|
+
0x0000000000000000, 0x7ad870c830358979, 0xf5b0e190606b12f2, 0x8f689158505e9b8b,
|
18
|
+
0xc038e5739841b68f, 0xbae095bba8743ff6, 0x358804e3f82aa47d, 0x4f50742bc81f2d04,
|
19
|
+
0xab28ecb46814fe75, 0xd1f09c7c5821770c, 0x5e980d24087fec87, 0x24407dec384a65fe,
|
20
|
+
0x6b1009c7f05548fa, 0x11c8790fc060c183, 0x9ea0e857903e5a08, 0xe478989fa00bd371,
|
21
|
+
0x7d08ff3b88be6f81, 0x07d08ff3b88be6f8, 0x88b81eabe8d57d73, 0xf2606e63d8e0f40a,
|
22
|
+
0xbd301a4810ffd90e, 0xc7e86a8020ca5077, 0x4880fbd87094cbfc, 0x32588b1040a14285,
|
23
|
+
0xd620138fe0aa91f4, 0xacf86347d09f188d, 0x2390f21f80c18306, 0x594882d7b0f40a7f,
|
24
|
+
0x1618f6fc78eb277b, 0x6cc0863448deae02, 0xe3a8176c18803589, 0x997067a428b5bcf0,
|
25
|
+
0xfa11fe77117cdf02, 0x80c98ebf2149567b, 0x0fa11fe77117cdf0, 0x75796f2f41224489,
|
26
|
+
0x3a291b04893d698d, 0x40f16bccb908e0f4, 0xcf99fa94e9567b7f, 0xb5418a5cd963f206,
|
27
|
+
0x513912c379682177, 0x2be1620b495da80e, 0xa489f35319033385, 0xde51839b2936bafc,
|
28
|
+
0x9101f7b0e12997f8, 0xebd98778d11c1e81, 0x64b116208142850a, 0x1e6966e8b1770c73,
|
29
|
+
0x8719014c99c2b083, 0xfdc17184a9f739fa, 0x72a9e0dcf9a9a271, 0x08719014c99c2b08,
|
30
|
+
0x4721e43f0183060c, 0x3df994f731b68f75, 0xb29105af61e814fe, 0xc849756751dd9d87,
|
31
|
+
0x2c31edf8f1d64ef6, 0x56e99d30c1e3c78f, 0xd9810c6891bd5c04, 0xa3597ca0a188d57d,
|
32
|
+
0xec09088b6997f879, 0x96d1784359a27100, 0x19b9e91b09fcea8b, 0x636199d339c963f2,
|
33
|
+
0xdf7adabd7a6e2d6f, 0xa5a2aa754a5ba416, 0x2aca3b2d1a053f9d, 0x50124be52a30b6e4,
|
34
|
+
0x1f423fcee22f9be0, 0x659a4f06d21a1299, 0xeaf2de5e82448912, 0x902aae96b271006b,
|
35
|
+
0x74523609127ad31a, 0x0e8a46c1224f5a63, 0x81e2d7997211c1e8, 0xfb3aa75142244891,
|
36
|
+
0xb46ad37a8a3b6595, 0xceb2a3b2ba0eecec, 0x41da32eaea507767, 0x3b024222da65fe1e,
|
37
|
+
0xa2722586f2d042ee, 0xd8aa554ec2e5cb97, 0x57c2c41692bb501c, 0x2d1ab4dea28ed965,
|
38
|
+
0x624ac0f56a91f461, 0x1892b03d5aa47d18, 0x97fa21650afae693, 0xed2251ad3acf6fea,
|
39
|
+
0x095ac9329ac4bc9b, 0x7382b9faaaf135e2, 0xfcea28a2faafae69, 0x8632586aca9a2710,
|
40
|
+
0xc9622c4102850a14, 0xb3ba5c8932b0836d, 0x3cd2cdd162ee18e6, 0x460abd1952db919f,
|
41
|
+
0x256b24ca6b12f26d, 0x5fb354025b277b14, 0xd0dbc55a0b79e09f, 0xaa03b5923b4c69e6,
|
42
|
+
0xe553c1b9f35344e2, 0x9f8bb171c366cd9b, 0x10e3202993385610, 0x6a3b50e1a30ddf69,
|
43
|
+
0x8e43c87e03060c18, 0xf49bb8b633338561, 0x7bf329ee636d1eea, 0x012b592653589793,
|
44
|
+
0x4e7b2d0d9b47ba97, 0x34a35dc5ab7233ee, 0xbbcbcc9dfb2ca865, 0xc113bc55cb19211c,
|
45
|
+
0x5863dbf1e3ac9dec, 0x22bbab39d3991495, 0xadd33a6183c78f1e, 0xd70b4aa9b3f20667,
|
46
|
+
0x985b3e827bed2b63, 0xe2834e4a4bd8a21a, 0x6debdf121b863991, 0x1733afda2bb3b0e8,
|
47
|
+
0xf34b37458bb86399, 0x8993478dbb8deae0, 0x06fbd6d5ebd3716b, 0x7c23a61ddbe6f812,
|
48
|
+
0x3373d23613f9d516, 0x49aba2fe23cc5c6f, 0xc6c333a67392c7e4, 0xbc1b436e43a74e9d,
|
49
|
+
0x95ac9329ac4bc9b5, 0xef74e3e19c7e40cc, 0x601c72b9cc20db47, 0x1ac40271fc15523e,
|
50
|
+
0x5594765a340a7f3a, 0x2f4c0692043ff643, 0xa02497ca54616dc8, 0xdafce7026454e4b1,
|
51
|
+
0x3e847f9dc45f37c0, 0x445c0f55f46abeb9, 0xcb349e0da4342532, 0xb1eceec59401ac4b,
|
52
|
+
0xfebc9aee5c1e814f, 0x8464ea266c2b0836, 0x0b0c7b7e3c7593bd, 0x71d40bb60c401ac4,
|
53
|
+
0xe8a46c1224f5a634, 0x927c1cda14c02f4d, 0x1d148d82449eb4c6, 0x67ccfd4a74ab3dbf,
|
54
|
+
0x289c8961bcb410bb, 0x5244f9a98c8199c2, 0xdd2c68f1dcdf0249, 0xa7f41839ecea8b30,
|
55
|
+
0x438c80a64ce15841, 0x3954f06e7cd4d138, 0xb63c61362c8a4ab3, 0xcce411fe1cbfc3ca,
|
56
|
+
0x83b465d5d4a0eece, 0xf96c151de49567b7, 0x76048445b4cbfc3c, 0x0cdcf48d84fe7545,
|
57
|
+
0x6fbd6d5ebd3716b7, 0x15651d968d029fce, 0x9a0d8ccedd5c0445, 0xe0d5fc06ed698d3c,
|
58
|
+
0xaf85882d2576a038, 0xd55df8e515432941, 0x5a3569bd451db2ca, 0x20ed197575283bb3,
|
59
|
+
0xc49581ead523e8c2, 0xbe4df122e51661bb, 0x3125607ab548fa30, 0x4bfd10b2857d7349,
|
60
|
+
0x04ad64994d625e4d, 0x7e7514517d57d734, 0xf11d85092d094cbf, 0x8bc5f5c11d3cc5c6,
|
61
|
+
0x12b5926535897936, 0x686de2ad05bcf04f, 0xe70573f555e26bc4, 0x9ddd033d65d7e2bd,
|
62
|
+
0xd28d7716adc8cfb9, 0xa85507de9dfd46c0, 0x273d9686cda3dd4b, 0x5de5e64efd965432,
|
63
|
+
0xb99d7ed15d9d8743, 0xc3450e196da80e3a, 0x4c2d9f413df695b1, 0x36f5ef890dc31cc8,
|
64
|
+
0x79a59ba2c5dc31cc, 0x037deb6af5e9b8b5, 0x8c157a32a5b7233e, 0xf6cd0afa9582aa47,
|
65
|
+
0x4ad64994d625e4da, 0x300e395ce6106da3, 0xbf66a804b64ef628, 0xc5bed8cc867b7f51,
|
66
|
+
0x8aeeace74e645255, 0xf036dc2f7e51db2c, 0x7f5e4d772e0f40a7, 0x05863dbf1e3ac9de,
|
67
|
+
0xe1fea520be311aaf, 0x9b26d5e88e0493d6, 0x144e44b0de5a085d, 0x6e963478ee6f8124,
|
68
|
+
0x21c640532670ac20, 0x5b1e309b16452559, 0xd476a1c3461bbed2, 0xaeaed10b762e37ab,
|
69
|
+
0x37deb6af5e9b8b5b, 0x4d06c6676eae0222, 0xc26e573f3ef099a9, 0xb8b627f70ec510d0,
|
70
|
+
0xf7e653dcc6da3dd4, 0x8d3e2314f6efb4ad, 0x0256b24ca6b12f26, 0x788ec2849684a65f,
|
71
|
+
0x9cf65a1b368f752e, 0xe62e2ad306bafc57, 0x6946bb8b56e467dc, 0x139ecb4366d1eea5,
|
72
|
+
0x5ccebf68aecec3a1, 0x2616cfa09efb4ad8, 0xa97e5ef8cea5d153, 0xd3a62e30fe90582a,
|
73
|
+
0xb0c7b7e3c7593bd8, 0xca1fc72bf76cb2a1, 0x45775673a732292a, 0x3faf26bb9707a053,
|
74
|
+
0x70ff52905f188d57, 0x0a2722586f2d042e, 0x854fb3003f739fa5, 0xff97c3c80f4616dc,
|
75
|
+
0x1bef5b57af4dc5ad, 0x61372b9f9f784cd4, 0xee5fbac7cf26d75f, 0x9487ca0fff135e26,
|
76
|
+
0xdbd7be24370c7322, 0xa10fceec0739fa5b, 0x2e675fb4576761d0, 0x54bf2f7c6752e8a9,
|
77
|
+
0xcdcf48d84fe75459, 0xb71738107fd2dd20, 0x387fa9482f8c46ab, 0x42a7d9801fb9cfd2,
|
78
|
+
0x0df7adabd7a6e2d6, 0x772fdd63e7936baf, 0xf8474c3bb7cdf024, 0x829f3cf387f8795d,
|
79
|
+
0x66e7a46c27f3aa2c, 0x1c3fd4a417c62355, 0x935745fc4798b8de, 0xe98f353477ad31a7,
|
80
|
+
0xa6df411fbfb21ca3, 0xdc0731d78f8795da, 0x536fa08fdfd90e51, 0x29b7d047efec8728
|
81
|
+
]
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'digest/crc64'
|
2
|
+
|
3
|
+
module Digest
|
4
|
+
#
|
5
|
+
# Implements the CRC64 XZ algorithm.
|
6
|
+
#
|
7
|
+
# @since 0.5.0
|
8
|
+
#
|
9
|
+
class CRC64XZ < 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 --model=crc-64-xz --generate=c`
|
18
|
+
TABLE = [
|
19
|
+
0x0000000000000000, 0xb32e4cbe03a75f6f, 0xf4843657a840a05b, 0x47aa7ae9abe7ff34,
|
20
|
+
0x7bd0c384ff8f5e33, 0xc8fe8f3afc28015c, 0x8f54f5d357cffe68, 0x3c7ab96d5468a107,
|
21
|
+
0xf7a18709ff1ebc66, 0x448fcbb7fcb9e309, 0x0325b15e575e1c3d, 0xb00bfde054f94352,
|
22
|
+
0x8c71448d0091e255, 0x3f5f08330336bd3a, 0x78f572daa8d1420e, 0xcbdb3e64ab761d61,
|
23
|
+
0x7d9ba13851336649, 0xceb5ed8652943926, 0x891f976ff973c612, 0x3a31dbd1fad4997d,
|
24
|
+
0x064b62bcaebc387a, 0xb5652e02ad1b6715, 0xf2cf54eb06fc9821, 0x41e11855055bc74e,
|
25
|
+
0x8a3a2631ae2dda2f, 0x39146a8fad8a8540, 0x7ebe1066066d7a74, 0xcd905cd805ca251b,
|
26
|
+
0xf1eae5b551a2841c, 0x42c4a90b5205db73, 0x056ed3e2f9e22447, 0xb6409f5cfa457b28,
|
27
|
+
0xfb374270a266cc92, 0x48190ecea1c193fd, 0x0fb374270a266cc9, 0xbc9d3899098133a6,
|
28
|
+
0x80e781f45de992a1, 0x33c9cd4a5e4ecdce, 0x7463b7a3f5a932fa, 0xc74dfb1df60e6d95,
|
29
|
+
0x0c96c5795d7870f4, 0xbfb889c75edf2f9b, 0xf812f32ef538d0af, 0x4b3cbf90f69f8fc0,
|
30
|
+
0x774606fda2f72ec7, 0xc4684a43a15071a8, 0x83c230aa0ab78e9c, 0x30ec7c140910d1f3,
|
31
|
+
0x86ace348f355aadb, 0x3582aff6f0f2f5b4, 0x7228d51f5b150a80, 0xc10699a158b255ef,
|
32
|
+
0xfd7c20cc0cdaf4e8, 0x4e526c720f7dab87, 0x09f8169ba49a54b3, 0xbad65a25a73d0bdc,
|
33
|
+
0x710d64410c4b16bd, 0xc22328ff0fec49d2, 0x85895216a40bb6e6, 0x36a71ea8a7ace989,
|
34
|
+
0x0adda7c5f3c4488e, 0xb9f3eb7bf06317e1, 0xfe5991925b84e8d5, 0x4d77dd2c5823b7ba,
|
35
|
+
0x64b62bcaebc387a1, 0xd7986774e864d8ce, 0x90321d9d438327fa, 0x231c512340247895,
|
36
|
+
0x1f66e84e144cd992, 0xac48a4f017eb86fd, 0xebe2de19bc0c79c9, 0x58cc92a7bfab26a6,
|
37
|
+
0x9317acc314dd3bc7, 0x2039e07d177a64a8, 0x67939a94bc9d9b9c, 0xd4bdd62abf3ac4f3,
|
38
|
+
0xe8c76f47eb5265f4, 0x5be923f9e8f53a9b, 0x1c4359104312c5af, 0xaf6d15ae40b59ac0,
|
39
|
+
0x192d8af2baf0e1e8, 0xaa03c64cb957be87, 0xeda9bca512b041b3, 0x5e87f01b11171edc,
|
40
|
+
0x62fd4976457fbfdb, 0xd1d305c846d8e0b4, 0x96797f21ed3f1f80, 0x2557339fee9840ef,
|
41
|
+
0xee8c0dfb45ee5d8e, 0x5da24145464902e1, 0x1a083bacedaefdd5, 0xa9267712ee09a2ba,
|
42
|
+
0x955cce7fba6103bd, 0x267282c1b9c65cd2, 0x61d8f8281221a3e6, 0xd2f6b4961186fc89,
|
43
|
+
0x9f8169ba49a54b33, 0x2caf25044a02145c, 0x6b055fede1e5eb68, 0xd82b1353e242b407,
|
44
|
+
0xe451aa3eb62a1500, 0x577fe680b58d4a6f, 0x10d59c691e6ab55b, 0xa3fbd0d71dcdea34,
|
45
|
+
0x6820eeb3b6bbf755, 0xdb0ea20db51ca83a, 0x9ca4d8e41efb570e, 0x2f8a945a1d5c0861,
|
46
|
+
0x13f02d374934a966, 0xa0de61894a93f609, 0xe7741b60e174093d, 0x545a57dee2d35652,
|
47
|
+
0xe21ac88218962d7a, 0x5134843c1b317215, 0x169efed5b0d68d21, 0xa5b0b26bb371d24e,
|
48
|
+
0x99ca0b06e7197349, 0x2ae447b8e4be2c26, 0x6d4e3d514f59d312, 0xde6071ef4cfe8c7d,
|
49
|
+
0x15bb4f8be788911c, 0xa6950335e42fce73, 0xe13f79dc4fc83147, 0x521135624c6f6e28,
|
50
|
+
0x6e6b8c0f1807cf2f, 0xdd45c0b11ba09040, 0x9aefba58b0476f74, 0x29c1f6e6b3e0301b,
|
51
|
+
0xc96c5795d7870f42, 0x7a421b2bd420502d, 0x3de861c27fc7af19, 0x8ec62d7c7c60f076,
|
52
|
+
0xb2bc941128085171, 0x0192d8af2baf0e1e, 0x4638a2468048f12a, 0xf516eef883efae45,
|
53
|
+
0x3ecdd09c2899b324, 0x8de39c222b3eec4b, 0xca49e6cb80d9137f, 0x7967aa75837e4c10,
|
54
|
+
0x451d1318d716ed17, 0xf6335fa6d4b1b278, 0xb199254f7f564d4c, 0x02b769f17cf11223,
|
55
|
+
0xb4f7f6ad86b4690b, 0x07d9ba1385133664, 0x4073c0fa2ef4c950, 0xf35d8c442d53963f,
|
56
|
+
0xcf273529793b3738, 0x7c0979977a9c6857, 0x3ba3037ed17b9763, 0x888d4fc0d2dcc80c,
|
57
|
+
0x435671a479aad56d, 0xf0783d1a7a0d8a02, 0xb7d247f3d1ea7536, 0x04fc0b4dd24d2a59,
|
58
|
+
0x3886b22086258b5e, 0x8ba8fe9e8582d431, 0xcc0284772e652b05, 0x7f2cc8c92dc2746a,
|
59
|
+
0x325b15e575e1c3d0, 0x8175595b76469cbf, 0xc6df23b2dda1638b, 0x75f16f0cde063ce4,
|
60
|
+
0x498bd6618a6e9de3, 0xfaa59adf89c9c28c, 0xbd0fe036222e3db8, 0x0e21ac88218962d7,
|
61
|
+
0xc5fa92ec8aff7fb6, 0x76d4de52895820d9, 0x317ea4bb22bfdfed, 0x8250e80521188082,
|
62
|
+
0xbe2a516875702185, 0x0d041dd676d77eea, 0x4aae673fdd3081de, 0xf9802b81de97deb1,
|
63
|
+
0x4fc0b4dd24d2a599, 0xfceef8632775faf6, 0xbb44828a8c9205c2, 0x086ace348f355aad,
|
64
|
+
0x34107759db5dfbaa, 0x873e3be7d8faa4c5, 0xc094410e731d5bf1, 0x73ba0db070ba049e,
|
65
|
+
0xb86133d4dbcc19ff, 0x0b4f7f6ad86b4690, 0x4ce50583738cb9a4, 0xffcb493d702be6cb,
|
66
|
+
0xc3b1f050244347cc, 0x709fbcee27e418a3, 0x3735c6078c03e797, 0x841b8ab98fa4b8f8,
|
67
|
+
0xadda7c5f3c4488e3, 0x1ef430e13fe3d78c, 0x595e4a08940428b8, 0xea7006b697a377d7,
|
68
|
+
0xd60abfdbc3cbd6d0, 0x6524f365c06c89bf, 0x228e898c6b8b768b, 0x91a0c532682c29e4,
|
69
|
+
0x5a7bfb56c35a3485, 0xe955b7e8c0fd6bea, 0xaeffcd016b1a94de, 0x1dd181bf68bdcbb1,
|
70
|
+
0x21ab38d23cd56ab6, 0x9285746c3f7235d9, 0xd52f0e859495caed, 0x6601423b97329582,
|
71
|
+
0xd041dd676d77eeaa, 0x636f91d96ed0b1c5, 0x24c5eb30c5374ef1, 0x97eba78ec690119e,
|
72
|
+
0xab911ee392f8b099, 0x18bf525d915feff6, 0x5f1528b43ab810c2, 0xec3b640a391f4fad,
|
73
|
+
0x27e05a6e926952cc, 0x94ce16d091ce0da3, 0xd3646c393a29f297, 0x604a2087398eadf8,
|
74
|
+
0x5c3099ea6de60cff, 0xef1ed5546e415390, 0xa8b4afbdc5a6aca4, 0x1b9ae303c601f3cb,
|
75
|
+
0x56ed3e2f9e224471, 0xe5c372919d851b1e, 0xa26908783662e42a, 0x114744c635c5bb45,
|
76
|
+
0x2d3dfdab61ad1a42, 0x9e13b115620a452d, 0xd9b9cbfcc9edba19, 0x6a978742ca4ae576,
|
77
|
+
0xa14cb926613cf817, 0x1262f598629ba778, 0x55c88f71c97c584c, 0xe6e6c3cfcadb0723,
|
78
|
+
0xda9c7aa29eb3a624, 0x69b2361c9d14f94b, 0x2e184cf536f3067f, 0x9d36004b35545910,
|
79
|
+
0x2b769f17cf112238, 0x9858d3a9ccb67d57, 0xdff2a94067518263, 0x6cdce5fe64f6dd0c,
|
80
|
+
0x50a65c93309e7c0b, 0xe388102d33392364, 0xa4226ac498dedc50, 0x170c267a9b79833f,
|
81
|
+
0xdcd7181e300f9e5e, 0x6ff954a033a8c131, 0x28532e49984f3e05, 0x9b7d62f79be8616a,
|
82
|
+
0xa707db9acf80c06d, 0x14299724cc279f02, 0x5383edcd67c06036, 0xe0ada17364673f59
|
83
|
+
]
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
data/lib/digest/crc8_1wire.rb
CHANGED
@@ -4,7 +4,7 @@ module Digest
|
|
4
4
|
#
|
5
5
|
# Implements the CRC8 1-Wire algorithm.
|
6
6
|
#
|
7
|
-
class
|
7
|
+
class CRC8_1Wire < CRC8
|
8
8
|
|
9
9
|
# Generated by `./pycrc.py --algorithm=table-driven --model=dallas-1-wire --generate=c`
|
10
10
|
TABLE = [
|
@@ -27,4 +27,7 @@ module Digest
|
|
27
27
|
].freeze
|
28
28
|
|
29
29
|
end
|
30
|
+
|
31
|
+
# @deprecated Please use {CRC8_1Wire} instead.
|
32
|
+
CRC81Wire = CRC8_1Wire
|
30
33
|
end
|
data/spec/crc15_spec.rb
ADDED
data/spec/crc32_mpeg_spec.rb
CHANGED
@@ -2,9 +2,15 @@ require 'spec_helper'
|
|
2
2
|
require 'crc_examples'
|
3
3
|
require 'digest/crc32_mpeg'
|
4
4
|
|
5
|
-
describe Digest::
|
5
|
+
describe Digest::CRC32MPEG do
|
6
6
|
let(:string) { '1234567890' }
|
7
7
|
let(:expected) { 'af97ac49' }
|
8
8
|
|
9
9
|
it_should_behave_like "CRC"
|
10
10
|
end
|
11
|
+
|
12
|
+
describe "Digest::CRC32Mpeg" do
|
13
|
+
subject { Digest::CRC32Mpeg }
|
14
|
+
|
15
|
+
it { expect(subject).to eq(Digest::CRC32MPEG) }
|
16
|
+
end
|
data/spec/crc8_1wire_spec.rb
CHANGED
@@ -2,9 +2,15 @@ require 'spec_helper'
|
|
2
2
|
require 'crc_examples'
|
3
3
|
require 'digest/crc8_1wire'
|
4
4
|
|
5
|
-
describe Digest::
|
5
|
+
describe Digest::CRC8_1Wire do
|
6
6
|
let(:string) { '1234567890' }
|
7
7
|
let(:expected) { '4f' }
|
8
8
|
|
9
9
|
it_should_behave_like "CRC"
|
10
10
|
end
|
11
|
+
|
12
|
+
describe "Digest::CRC81Wire" do
|
13
|
+
subject { Digest::CRC81Wire }
|
14
|
+
|
15
|
+
it { expect(subject).to eq(Digest::CRC8_1Wire) }
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: digest-crc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
description: Adds support for calculating Cyclic Redundancy Check (CRC) to the Digest
|
28
28
|
module.
|
29
29
|
email: postmodern.mod3@gmail.com
|
@@ -48,36 +48,56 @@ files:
|
|
48
48
|
- gemspec.yml
|
49
49
|
- lib/digest/crc.rb
|
50
50
|
- lib/digest/crc1.rb
|
51
|
+
- lib/digest/crc15.rb
|
51
52
|
- lib/digest/crc16.rb
|
52
53
|
- lib/digest/crc16_ccitt.rb
|
53
54
|
- lib/digest/crc16_dnp.rb
|
55
|
+
- lib/digest/crc16_genibus.rb
|
56
|
+
- lib/digest/crc16_kermit.rb
|
54
57
|
- lib/digest/crc16_modbus.rb
|
55
58
|
- lib/digest/crc16_qt.rb
|
56
59
|
- lib/digest/crc16_usb.rb
|
60
|
+
- lib/digest/crc16_x_25.rb
|
57
61
|
- lib/digest/crc16_xmodem.rb
|
58
62
|
- lib/digest/crc16_zmodem.rb
|
59
63
|
- lib/digest/crc24.rb
|
60
64
|
- lib/digest/crc32.rb
|
65
|
+
- lib/digest/crc32_bzip2.rb
|
66
|
+
- lib/digest/crc32_jam.rb
|
61
67
|
- lib/digest/crc32_mpeg.rb
|
68
|
+
- lib/digest/crc32_posix.rb
|
69
|
+
- lib/digest/crc32_xfer.rb
|
62
70
|
- lib/digest/crc32c.rb
|
63
71
|
- lib/digest/crc5.rb
|
64
72
|
- lib/digest/crc64.rb
|
73
|
+
- lib/digest/crc64_jones.rb
|
74
|
+
- lib/digest/crc64_xz.rb
|
65
75
|
- lib/digest/crc8.rb
|
66
76
|
- lib/digest/crc8_1wire.rb
|
77
|
+
- spec/crc15_spec.rb
|
67
78
|
- spec/crc16_ccitt_spec.rb
|
79
|
+
- spec/crc16_genibus_spec.rb
|
80
|
+
- spec/crc16_kermit_spec.rb
|
68
81
|
- spec/crc16_modbus_spec.rb
|
69
82
|
- spec/crc16_qt_spec.rb
|
70
83
|
- spec/crc16_spec.rb
|
71
84
|
- spec/crc16_usb_spec.rb
|
85
|
+
- spec/crc16_x_25_spec.rb
|
72
86
|
- spec/crc16_xmodem_spec.rb
|
73
87
|
- spec/crc16_zmodem_spec.rb
|
74
88
|
- spec/crc1_spec.rb
|
75
89
|
- spec/crc24_spec.rb
|
90
|
+
- spec/crc32_bzip_spec.rb
|
91
|
+
- spec/crc32_jam_spec.rb
|
76
92
|
- spec/crc32_mpeg_spec.rb
|
93
|
+
- spec/crc32_posix_spec.rb
|
77
94
|
- spec/crc32_spec.rb
|
95
|
+
- spec/crc32_xfer_spec.rb
|
78
96
|
- spec/crc32c_spec.rb
|
79
97
|
- spec/crc5_spec.rb
|
98
|
+
- spec/crc64_jones_spec.rb
|
80
99
|
- spec/crc64_spec.rb
|
100
|
+
- spec/crc64_xz_spec.rb
|
81
101
|
- spec/crc8_1wire_spec.rb
|
82
102
|
- spec/crc8_spec.rb
|
83
103
|
- spec/crc_examples.rb
|