Skip to content

Latest commit

 

History

History

python3

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

JSON Canonicalizer for Python

The src/org/webpki/json folder contains the source code for a JCS (RFC 8785) compliant canonicalizer written in Python.

Building and testing

  • Set PYTHONPATH to the src directory.

  • For running verify-numbers.py you 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 in verify-numbers.py.

  • Perform the commands:

$ cd test
$ python verify-canonicalization.py
$ python verify-numbers.py

Using the JSON canonicalizer

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}'))