cbor-canonical 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cbor-canonical.gemspec +1 -1
- data/lib/cbor-canonical.rb +5 -2
- data/test/test-canonical.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab062f791bce0e81297faecdc9ce7b1c262691de
|
4
|
+
data.tar.gz: 6366480206eba1c826dafbeec27127d18e9d5bda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1be468685e551d3f557a08f85f6afd3dd2e5fe7a866df7744c0186a20d733309795c2f937d8682eeabb33286fb110c9742b87f5fc31d34c345727f1cbd8d57b
|
7
|
+
data.tar.gz: c88d13767f70598fffb1fbdec87cf64f94b685bf0f0c53ea299aea0d5a4f49454e7c2f696c04db51a933da372900e1e9eac21ec715702433af39137b30c1e5e6
|
data/cbor-canonical.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cbor-canonical"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.1"
|
4
4
|
s.summary = "CBOR (Concise Binary Object Representation) canonical encoding"
|
5
5
|
s.description = %q{cbor-canonical implements canonical encoding for CBOR, RFC 7049 Section 3.9}
|
6
6
|
s.author = "Carsten Bormann"
|
data/lib/cbor-canonical.rb
CHANGED
@@ -24,8 +24,11 @@ module CBOR
|
|
24
24
|
|
25
25
|
module Hash_Canonical_CBOR
|
26
26
|
def cbor_pre_canonicalize
|
27
|
-
Hash[map {|k, v|
|
28
|
-
|
27
|
+
Hash[map {|k, v|
|
28
|
+
k = k.cbor_pre_canonicalize
|
29
|
+
v = v.cbor_pre_canonicalize
|
30
|
+
cc = k.to_cbor # already canonical
|
31
|
+
[cc.size, cc, k, v]}.
|
29
32
|
sort.map{|s, cc, k, v| [k, v]}]
|
30
33
|
end
|
31
34
|
end
|
data/test/test-canonical.rb
CHANGED
@@ -3,6 +3,7 @@ require 'cbor-canonical'
|
|
3
3
|
[[1], [false], [10.3], [10.5], [Float::NAN],
|
4
4
|
[{a: 1, b: [1, 2]}],
|
5
5
|
[{aa: 1, b: 2}, {b: 2, aa: 1}],
|
6
|
+
[{aa: 1, b: {mm: 2, m: 3}}, {b: {m: 3, mm: 2}, aa: 1}],
|
6
7
|
[CBOR::Tagged.new(4711, {aa: 1, b: 2}),
|
7
8
|
CBOR::Tagged.new(4711, {b: 2, aa: 1})],
|
8
9
|
].each do |ex1, ex2, ex3|
|