The src/org/webpki/json folder contains the source code for a JCS (RFC 8785) compliant canonicalizer written in Python.
-
Set PYTHONPATH to the
srcdirectory. -
For running
verify-numbers.pyyou need to download a 3Gb+ file with test data described in the root directory testdata. This file can be stored in any directory and requires updating the file path inverify-numbers.py. -
Perform the commands:
$ cd test
$ python verify-canonicalization.py
$ python verify-numbers.py
from org.webpki.json.Canonicalize import canonicalize
data = canonicalize({"tag":4})Note that the input is Python data structures while result is an UTF-8 formatted byte array.
If you rather need a free-standing canonicalizer you can achive that by using standard Python tools:
from org.webpki.json.Canonicalize import canonicalize
from json import loads
data = canonicalize(loads('{"tag":4}'))