ffc16 0.0.2
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 +7 -0
- data/bin/ffc16 +4 -0
- data/lib/ffc16.rb +36 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2b33652fe224bc4ec550e930d5e3e6018c795c04444da3b813f665b066e3d958
|
|
4
|
+
data.tar.gz: 8ad6cd3526ef195ffac575b2e9363126494da05db2f30c3425b5b5562703879b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: dc2d7a74c1347f3a9e2b924744c05482b73dd50eb68437ebc380d9dd608551bf26d55337a45a0baca89b91ac8804306bdaaf2892156c75b4427dcd8cd72bbd1a
|
|
7
|
+
data.tar.gz: 85335f3b6a60086b1bcd2acb4263b6d16796e8def248d1c96f821a4ed366b6934ee81ae99d2da01e3d9cf87bbb102cca62ca115440b392126401a7184583e428
|
data/bin/ffc16
ADDED
data/lib/ffc16.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
class Ffc16
|
|
2
|
+
|
|
3
|
+
MODX = 4102
|
|
4
|
+
|
|
5
|
+
def self.checksum(buf)
|
|
6
|
+
|
|
7
|
+
inx = 0
|
|
8
|
+
end_buf = buf.length
|
|
9
|
+
|
|
10
|
+
c0 = 0
|
|
11
|
+
c1 = 0
|
|
12
|
+
|
|
13
|
+
loop do
|
|
14
|
+
|
|
15
|
+
end_chunk = (inx + MODX < end_buf) ? inx + MODX : end_buf
|
|
16
|
+
|
|
17
|
+
loop do
|
|
18
|
+
|
|
19
|
+
c0 += 0xff & buf[inx].ord
|
|
20
|
+
c1 += c0
|
|
21
|
+
|
|
22
|
+
inx += 1
|
|
23
|
+
break unless inx < end_chunk
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
c0 %= 255
|
|
27
|
+
c1 %= 255
|
|
28
|
+
|
|
29
|
+
break unless inx < end_buf
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
c1 << 8 | c0
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ffc16
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- David E. Smyth
|
|
8
|
+
- Jesse J. Wright
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2020-02-05 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: An optimized implementation of Fletcher16 checksum
|
|
15
|
+
email: DESmyth@HoneybeeRobotics.com
|
|
16
|
+
executables:
|
|
17
|
+
- ffc16
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- bin/ffc16
|
|
22
|
+
- lib/ffc16.rb
|
|
23
|
+
homepage: https://en.wikipedia.org/wiki/Fletcher%27s_checksum
|
|
24
|
+
licenses:
|
|
25
|
+
- MIT
|
|
26
|
+
metadata: {}
|
|
27
|
+
post_install_message:
|
|
28
|
+
rdoc_options: []
|
|
29
|
+
require_paths:
|
|
30
|
+
- lib
|
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '0'
|
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
requirements: []
|
|
42
|
+
rubygems_version: 3.0.3
|
|
43
|
+
signing_key:
|
|
44
|
+
specification_version: 4
|
|
45
|
+
summary: Fast Fletcher16 Checksum
|
|
46
|
+
test_files: []
|