Performs the C14N transformation of a straightforward XML document.
The following C14N transformations are supported:
“inclusive canonicalization” from Canonical XML
Version 1.0 (reproduced as RFC 3076) with
identifiers
http://www.w3.org/TR/2001/REC-xml-c14n-20010315``http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments
“exclusive canonicalization” from Exclusive
XML Canonical Version 1.0 (reproduced as RFC 3741) with
identifiers
http://www.w3.org/2001/10/xml-exc-c14n#``http://www.w3.org/2001/10/xml-exc-c14n#WithComments
Input is expected to be a well-formed XML document. Supported XML
encodings are UTF-8, ISO-8859-1 and
US-ASCII.
| Class | Description |
|---|---|
| C14n | Performs C14N transformation of XML document. |
| Err | Details of errors returned by the core library. |
| Gen | General info about the core library DLL. |
| Enumeration | Description |
|---|---|
| AdvOptions | Advanced option flags |
| DigAlg | Digest Algorithm |
| Tran | Transformation options to specify the document part to be canonicalized. |
| TranMethod | Transformation methods |
Performs C14N transformation of XML document.
System.Object
Sc14n.C14n
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public class C14nThe C14n type exposes the following members.
| Name | Description |
|---|---|
| ToBytes(Byte[], String, Tran, TranMethod, String, AdvOptions) | Performs C14N transformation of XML document (memory-to-memory with options). |
| ToBytes(String, String, Tran, TranMethod, String, AdvOptions) | Performs C14N transformation of XML document. |
| ToDigest(Byte[], DigAlg) | Computes digest value of inclusive C14N transformation of entire XML document (memory-to-digest). |
| ToDigest(String, DigAlg) | Computes digest value of inclusive C14N transformation of entire XML document (file-to-digest). |
| ToDigest(Byte[], String, Tran, DigAlg, TranMethod, String, AdvOptions) | Computes digest value of C14N transformation of XML document (memory-to-digest). |
| ToDigest(String, String, Tran, DigAlg, TranMethod, String, AdvOptions) | Computes digest value of C14N transformation of XML document (file-to-digest). |
| ToFile | Performs C14N transformation of XML document (file-to-file). |
Performs C14N transformation of XML document (memory-to-memory with options).
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
| Name | Description |
|---|---|
| ToBytes(Byte[], String, Tran, TranMethod, String, AdvOptions) | Performs C14N transformation of XML document (memory-to-memory with options). |
| ToBytes(String, String, Tran, TranMethod, String, AdvOptions) | Performs C14N transformation of XML document. |
public static byte[] ToBytes(
byte[] xmlData,
string nameOrId = "",
Tran tranOpt = Tran.Entire,
TranMethod tranMethod = TranMethod.Inclusive,
string exclParams = "",
AdvOptions advOpts = AdvOptions.Default
)XML data to be processed.
Tag name or Id to include or omit [optional,
default=""]. See remarks for C14n.ToFile.
Transformation option [optional,
default=Tran.Entire].
Transformation method [optional,
default=TranMethod.Inclusive].
InclusiveNamespaces PrefixList parameter for exclusive c14n
[optional, default=""].
Option flags [optional, default=0].
Byte[]
UTF-8 encoded byte array
Performs C14N transformation of XML document.
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
| Name | Description |
|---|---|
| ToBytes(Byte[], String, Tran, TranMethod, String, AdvOptions) | Performs C14N transformation of XML document (memory-to-memory with options). |
| ToBytes(String, String, Tran, TranMethod, String, AdvOptions) | Performs C14N transformation of XML document. |
public static byte[] ToBytes(
string xmlFile,
string nameOrId = "",
Tran tranOpt = Tran.Entire,
TranMethod tranMethod = TranMethod.Inclusive,
string exclParams = "",
AdvOptions advOpts = AdvOptions.Default
)Name of input XML file.
Tag name or Id to include or omit [optional,
default=""]. See remarks for C14n.ToFile.
Transformation option [optional,
default=Tran.Entire].
Transformation method [optional,
default=TranMethod.Inclusive].
InclusiveNamespaces PrefixList parameter for exclusive c14n
[optional, default=""].
Option flags [optional, default=0].
Byte[]
UTF-8 encoded byte array
Computes digest value of inclusive C14N transformation of entire XML document (memory-to-digest).
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
| Name | Description |
|---|---|
| ToDigest(Byte[], DigAlg) | Computes digest value of inclusive C14N transformation of entire XML document (memory-to-digest). |
| ToDigest(String, DigAlg) | Computes digest value of inclusive C14N transformation of entire XML document (file-to-digest). |
| ToDigest(Byte[], String, Tran, DigAlg, TranMethod, String, AdvOptions) | Computes digest value of C14N transformation of XML document (memory-to-digest). |
| ToDigest(String, String, Tran, DigAlg, TranMethod, String, AdvOptions) | Computes digest value of C14N transformation of XML document (file-to-digest). |
public static string ToDigest(
byte[] xmlData,
DigAlg digAlg
)XML data to be processed
Digest algorithm
String
Digest value in base64 encoding or empty string on error (for more
details use Err.LastError).
Retrieves the last error message (if available).
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public static string LastError()String
Error message from last call (may be empty)
Call this immediately when an error is indicated. Calling another method will overwrite the message.
Computes digest value of inclusive C14N transformation of entire XML document (file-to-digest).
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
| Name | Description |
|---|---|
| ToDigest(Byte[], DigAlg) | Computes digest value of inclusive C14N transformation of entire XML document (memory-to-digest). |
| ToDigest(String, DigAlg) | Computes digest value of inclusive C14N transformation of entire XML document (file-to-digest). |
| ToDigest(Byte[], String, Tran, DigAlg, TranMethod, String, AdvOptions) | Computes digest value of C14N transformation of XML document (memory-to-digest). |
| ToDigest(String, String, Tran, DigAlg, TranMethod, String, AdvOptions) | Computes digest value of C14N transformation of XML document (file-to-digest). |
public static string ToDigest(
string xmlFile,
DigAlg digAlg
)Name of input XML file.
Digest algorithm
String
Digest value in base64 encoding or empty string on error (for more
details use Err.LastError).
Computes digest value of C14N transformation of XML document (memory-to-digest).
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
| Name | Description |
|---|---|
| ToDigest(Byte[], DigAlg) | Computes digest value of inclusive C14N transformation of entire XML document (memory-to-digest). |
| ToDigest(String, DigAlg) | Computes digest value of inclusive C14N transformation of entire XML document (file-to-digest). |
| ToDigest(Byte[], String, Tran, DigAlg, TranMethod, String, AdvOptions) | Computes digest value of C14N transformation of XML document (memory-to-digest). |
| ToDigest(String, String, Tran, DigAlg, TranMethod, String, AdvOptions) | Computes digest value of C14N transformation of XML document (file-to-digest). |
public static string ToDigest(
byte[] xmlData,
string nameOrId = "",
Tran tranOpt = Tran.Entire,
DigAlg digAlg = DigAlg.Default,
TranMethod tranMethod = TranMethod.Inclusive,
string exclParams = "",
AdvOptions advOpts = AdvOptions.Default
)XML data to be processed
Tag name or Id to include or omit [optional,
default=""]. See remarks for C14n.ToFile.
Transformation option [optional,
default=Tran.Entire].
Digest algorithm [optional, default=DigAlg.Default
SHA-1]
Transformation method [optional,
default=TranMethod.Inclusive].
InclusiveNamespaces PrefixList parameter for exclusive c14n
[optional, default=""].
Option flags [optional, default=0].
String
Digest value in base64 encoding or empty string on error (for more
details use Err.LastError).
Computes digest value of C14N transformation of XML document (file-to-digest).
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
| Name | Description |
|---|---|
| ToDigest(Byte[], DigAlg) | Computes digest value of inclusive C14N transformation of entire XML document (memory-to-digest). |
| ToDigest(String, DigAlg) | Computes digest value of inclusive C14N transformation of entire XML document (file-to-digest). |
| ToDigest(Byte[], String, Tran, DigAlg, TranMethod, String, AdvOptions) | Computes digest value of C14N transformation of XML document (memory-to-digest). |
| ToDigest(String, String, Tran, DigAlg, TranMethod, String, AdvOptions) | Computes digest value of C14N transformation of XML document (file-to-digest). |
public static string ToDigest(
string xmlFile,
string nameOrId = "",
Tran tranOpt = Tran.Entire,
DigAlg digAlg = DigAlg.Default,
TranMethod tranMethod = TranMethod.Inclusive,
string exclParams = "",
AdvOptions advOpts = AdvOptions.Default
)Name of input XML file.
Tag name or Id to include or omit [optional,
default=""]. See remarks for C14n.ToFile.
Transformation option [optional,
default=Tran.Entire].
Digest algorithm [optional, default=DigAlg.Default
SHA-1]
Transformation method [optional,
default=TranMethod.Inclusive].
InclusiveNamespaces PrefixList parameter for exclusive c14n
[optional, default=""].
Option flags [optional, default=0].
String
Digest value in base64 encoding or empty string on error (for more
details use Err.LastError).
Performs C14N transformation of XML document (file-to-file).
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public static int ToFile(
string outFile,
string xmlFile,
string nameOrId = "",
Tran tranOpt = Tran.Entire,
TranMethod tranMethod = TranMethod.Inclusive,
string exclParams = "",
AdvOptions advOpts = AdvOptions.Default
)Name of output file to create.
Name of input XML file.
Tag name or Id to include or omit [optional, default=""]
(see remarks below).
Transformation option [optional,
default=Tran.Entire].
Transformation method [optional,
default=TranMethod.Inclusive].
InclusiveNamespaces PrefixList parameter for exclusive c14n
[optional, default=""].
Option flags [optional, default=0].
Int32
0 if successful or non-zero error
code.
Use the nameOrId parameter to specify the element of the
XML document to include or omit.
With options OmitByTag or SubsetByTag, nameOrId
specifies the element’s tag name. By default, the first element with a
matching tag name will be chosen.To specify the Nth
element, write as tagname[N] where N=1,2,3,...
With options OmitById or SubsetById, nameOrId specifies
the element’s Id. The default Id attribute name is Id, so
the argument myvalue will find the element with attribute
Id="myvalue".To use a different attribute name - for
example ID - write in the form ID=myvalue with
no quotes. With option Entire, the parameter
is ignored, so just use "" or null.
Exactly one element will be omitted or included. Tag names and Id
values are case sensitive. It is an error (NO_DATA_ERROR)
if no matching element is found.
// Example 1. Omits the first element with the tag name <Signature>
r = C14n.ToFile("c14nfile1.txt", "input.xml", "Signature", Tran.OmitByTag);
// Example 2. Finds and transforms the first element with the tag name <SignedInfo>
r = C14n.ToFile("c14nfile2.txt", "input.xml", "SignedInfo", Tran.SubsetByTag);
// Example 3. Finds and transforms the third element with the tag name <Data>
r = C14n.ToFile("c14nfile3.txt", "input.xml", "Data[3]", Tran.SubsetByTag);
// Example 4. Finds and transforms the element with attribute Id="foo"
r = C14n.ToFile("c14nfile4.txt", "input.xml", "foo", Tran.SubsetById);
// Example 5. Finds and transforms the element with attribute ID="bar"
r = C14n.ToFile("c14nfile5.txt", "input.xml", "ID=bar", Tran.SubsetById);
// Example 6. Omits element with attribute Id="thesig"
r = C14n.ToFile("c14nfile6.txt", "input.xml", "thesig", Tran.OmitById);Looks up description for error code.
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public static string ErrorLookup(
int errCode
)Value of error code to lookup (may be positive or negative)
String
Corresponding error message
Details of errors returned by the core library.
System.Object
Sc14n.Err
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public class ErrThe Err type exposes the following members.
| Name | Description |
|---|---|
| ErrorLookup | Looks up description for error code. |
| LastError | Retrieves the last error message (if available). |
General info about the core library DLL.
System.Object
Sc14n.Gen
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public class GenThe Gen type exposes the following members.
| Name | Description |
|---|---|
| CompileTime | Gets date and time the core DLL module was last compiled. |
| LicenceType | Gets licence type. |
| ModuleName | Gets full path name of core DLL module. |
| Platform | Gets platform on which the core DLL is running. |
| Version | Gets version number of core diSc14n DLL. |
Gets date and time the core DLL module was last compiled.
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public static string CompileTime()String
Date and time string
Gets licence type.
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public static char LicenceType()Char
D=Developer T=Trial
Note the Australian/English spelling of “Licence”.
Gets full path name of core DLL module.
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public static string ModuleName()String
File name
Gets platform on which the core DLL is running.
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public static string Platform()String
"Win32" or "Win64"
Gets version number of core diSc14n DLL.
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public static int Version()Int32
Version number in form Major * 10000 + Minor * 100 + Release
E.g. version 1.2.3 returns 10203
Advanced option flags
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
[FlagsAttribute]
public enum AdvOptions| Member name | Description |
|---|---|
| Default | Default options. |
| Flatten | Flatten the XML - remove all ignorable whitespace between tags. |
Digest Algorithm
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public enum DigAlg| Member name | Description |
|---|---|
| Default | Use default digest algorithm (SHA-1) |
| Sha1 | Use SHA-1 digest algorithm (default) |
| Sha256 | Use SHA-256 digest algorithm |
| Sha384 | Use SHA-384 digest algorithm |
| Sha512 | Use SHA-512 digest algorithm |
Transformation options to specify the document part to be canonicalized.
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public enum Tran| Member name | Description |
|---|---|
| Entire | Transform the entire document. |
| OmitByTag | Omit the element with the given tag name. |
| SubsetByTag | Transform the subset with the given tag name. |
| OmitById | Omit the element with the given Id. |
| SubsetById | Transform the subset with the given Id. |
Sc14n Namespace
Remarks in C14n.ToFile
Transformation methods
Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version:
3.1.0.28355 (3.1.0.0)
public enum TranMethod| Member name | Description |
|---|---|
| Inclusive | Inclusive C14N without comments from RFC 3076. |
| Exclusive | Exclusive C14N without comments from RFC 3741. |
| InclusiveWithComments | Inclusive C14N with comments from RFC 3076. |
| ExclusiveWithComments | Exclusive C14N with comments from RFC 3741. |
Created: 2025-10-20 20:24:20
Copyright (C) 2025 D.I. Management Services Pty Ltd t/a CryptoSys https://cryptosys.net