| width='120' | '''SignaturesSignature'''|{{Func|crypto:hmac|$data as xs:anyAtomicType, $key as xs:anyAtomicType, $algorithm as xs:string|xs:string}}<br/pre>{{Func|crypto:hmac|( $data as xs:anyAtomicType, $key as xs:anyAtomicType, $algorithm as xs:string, $encoding as xs:string| := ()) as xs:string}}</pre>
|- valign="top"
| '''Summary'''
|Return message authentication code (MAC) for a given string:
'''Query:'''
<syntaxhighlight pre lang="'xquery"'>
crypto:hmac('message', 'secretkey', 'md5', 'hex')
</syntaxhighlightpre>
'''Result:'''
<syntaxhighlight pre lang="xml">
34D1E3818B347252A75A4F6D747B21C2
</syntaxhighlightpre>
|}
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>crypto:encrypt|( $data as xs:anyAtomicType, $type as xs:string, $key as xs:anyAtomicType, $algorithm as xs:string|) as xs:base64Binary}}</pre>
| width='120' | '''SignaturesSignature'''|{{Func|<pre>crypto:decrypt|( $data as xs:anyAtomicType, $type as xs:string, $key as xs:anyAtomicType, $algorithm as xs:string|) as xs:string}}</pre>
|- valign="top"
| '''Summary'''
|Decrypt input data and return original string:
'''Query:'''
<syntaxhighlight pre lang="'xquery"'>
let $encrypted := crypto:encrypt('message', 'symmetric', 'keykeyke', 'DES')
* '''SignedInfo''' contains or references the signed data and lists algorithm information
The {{Code|generate-signature}} function allows to pass a {{Code|digital certificate}}. This certificate holds parameters that allow to access key information stored in a Java key store which is then used to sign the input document. Passing a {{Code|digital certificate}} simply helps re-using the same key pair to sign and validate data. The {{Code|digital certificate}} is passed as a node and has the following form:
<syntaxhighlight pre lang="xml">
<digital-certificate>
<keystore-type>JKS</keystore-type>
<keystore-uri>...</keystore-uri>
</digital-certificate>
</syntaxhighlightpre>
==crypto:generate-signature==
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|crypto:generate-signature|$input as node(), $canonicalization as xs:string, $digest as xs:string, $signature as xs:string, $prefix as xs:string, $type as xs:string|node()}}<br/pre>{{Func|crypto:generate-signature|( $input as node(), $canonicalization as xs:string, $digest as xs:string, $signature as xs:string, $prefix as xs:string, $type as xs:string, $xpath ext1 as xs:stringitem(), $certificate ext2 as node()|) as node()}}<br/pre>{{Func|crypto:generate-signature|$input as node(), $canonicalization as xs:string, $digest as xs:string, $signature as xs:string, $prefix as xs:string, $type as xs:string, $ext as item()|node()}}
|- valign="top"
| '''Summary'''
{{Code|$prefix}} may be empty and prefixes the {{Code|Signature}} element accordingly.<br/>
{{Code|$type}} is the signature type. It must either be {{Code|enveloped}} or {{Code|enveloping}} (detached signatures are not supported so far). '''Default is {{Code|enveloped}}'''.<br/>
{{Code|$ext1}} may either be an {{Code|$xpath}} is an arbitrary XPath expression which specifies or a subset of the document that is to be signed.<br/>{{Code|$certificate}} is the digitial certificate used to sign the input document.<br/>If {{Code|$extext2}} may either be an is specified as well, {{Code|$xpathext1}} is an arbitrary XPath expression or which specifies a subset of the document that is to be signed, and {{Code|$certificateext2}}is the digitial certificate used to sign the input document.<br/>
| width='120' | '''SignaturesSignature'''|{{Func|<pre>crypto:validate-signature|( $input-doc as node()|) as xs:boolean}}</pre>
|- valign="top"
| '''Summary'''
| '''Errors'''
|{{Error|CX0015|#Errors}} the signature element cannot be found.<br/>{{Error|CX9994|#Errors}} an unspecified problem occurs during validation.<br/>{{Error|CX9996|#Errors}} an IO exception occurs during validation.<br/>
|- valign="top"
| '''Example'''
|Validate [https://www.w3.org/TR/xmldsig-core/ XML Signature]:
'''Query:'''
<syntaxhighlight lang="xquery">
let $sig := crypto:generate-signature(<a/>, '', '', '', '', '')