A Python interface to Sc14n

The utility Sc14n performs the C14N transformation of a straightforward XML document.

The transformation can be of the complete document, a subset of the document, or the document excluding a given subset. The subset can be specified either by its ID or tag name.

>>> # Example 1. Excludes the first element with the tag name <Signature>
>>> r = C14n.file2file("c14nfile1.txt", "input.xml", "Signature", Tran.OMITBYTAG)
>>> # Example 2. Finds and transforms the first element with the tag name <SignedInfo>
>>> r = C14n.file2file("c14nfile2.txt", "input.xml", "SignedInfo", Tran.SUBSETBYTAG)
>>> # Example 3. Finds and transforms the third element with the tag name <Data>
>>> r = C14n.file2file("c14nfile3.txt", "input.xml", "Data[3]", Tran.SUBSETBYTAG)
>>> # Example 4. Finds and transforms the element with attribute Id="foo"
>>> r = C14n.file2file("c14nfile4.txt", "input.xml", "foo", Tran.SUBSETBYID)
>>> # Example 5. Finds and transforms the element with attribute ID="bar"
>>> r = C14n.file2file("c14nfile5.txt", "input.xml", "ID=bar", Tran.SUBSETBYID)
>>> # Example 6. Excludes element with attribute Id="thesig"
>>> r = C14n.file2file("c14nfile6.txt", "input.xml", "thesig", Tran.OMITBYID)

For full details of all available methods and options, please see the documentation.

Sc14n can be used with a cryptographic library to sign XML documents using XML-DSIG. We recommend our cryptographic library CryptoSys PKI available from https://cryptosys.net/pki/.

System requirements

Windows platforms with Python 3. Requires the Windows program Sc14n to be installed on your system, available from https://cryptosys.net/sc14n/.

To carry out the cryptographic signing examples in test_sc14n-pki.py you must also install CryptoSys PKI and cryptosyspki.py (see links below).


For more information or to make suggestions, please contact us at https://cryptosys.net/contact/

David Ireland
DI Management Services Pty Ltd
28 December 2018