cabo / cbor-canonical

cbor-canonical implements canonical encoding for CBOR, RFC 7049 Section 3.9 in pure Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cbor-canonical gem

Use with the cbor gem (or with cbor-pure, which is a part of the cbor-diag gem) to add a to_canonical_cbor method on objects. Requires to_cbor to already be mostly canonical (as it is for the above two CBOR implementations), just adds canonical ordering of maps for completeness.

require 'cbor-canonical'

ex1 = {aa: 1, b: 2}

p CBOR.decode(ex1.to_cbor)
# {"aa"=>1, "b"=>2}

p CBOR.decode(ex1.to_canonical_cbor)
# {"b"=>2, "aa"=>1}

About

cbor-canonical implements canonical encoding for CBOR, RFC 7049 Section 3.9 in pure Ruby


Languages

Language:Ruby 100.0%