| '''Summary'''
|Creates a message authentication code via a cryptographic hash function and a secret key. <br/>
{{Code|$encoding}} must either be {{Code|hex}}, {{Code|base64}} or the empty string and specifies the encoding of the returned authentication code. <b>'''Default is {{Code|base64}}</b>'''.<br/>{{Code|$algorithm}} describes the hash algorithm which is used for encryption. Currently supported are {{Code|md5}}, {{Code|sha1}}, {{Code|sha256}}, {{Code|sha384}}, {{Code|sha512}}. <b>'''Default is {{Code|md5}}</b>'''.
|-
| '''Errors'''
|<b>[[{{Error|FOCX0013|XQuery Errors#Cryptographic Functions Errors|FOCX0013]]</b> is raised if }} the specified hashing algorithm is not supported.<br/><b>[[{{Error|FOCX0014|XQuery Errors#Cryptographic Functions Errors|FOCX0014]]</b> is raised if }} the specified encoding method is not supported.<br/><b>[[{{Error|FOCX0019|XQuery Errors#Cryptographic Functions Errors|FOCX0019]]</b> is raised if }} the specified secret key is invalid.<br/>
|-
| '''Example'''
| '''Summary'''
|Encrypts the given input string.<br/>
{{Code|$encryption-type}} must be {{Code|symmetric}}, as asymmetric encryption is not supported so far. <b>'''Default is {{Code|symmetric}}</b>'''.<br/>
{{Code|$secret-key}} is the secret key which is used for both encryption and decryption of input data. Its length is fixed and depends on the chosen algorithm: {{Code|8 bytes for DES}}, {{Code|16 bytes for AES}}.<br/>
{{Code|$cryptographic-algorithm}} must either be {{Code|DES}} or {{Code|AES}}. Other algorithms are not supported so far, but, of course, can be added on demand. <b>'''Default is {{Code|DES}}</b>'''.
|-
| '''Errors'''
|<b>[[{{Error|FOCX0016|XQuery Errors#Cryptographic Functions Errors|FOCX0016]]</b> is raised if }} padding problems arise.<br/><b>[[{{Error|FOCX0017|XQuery Errors#Cryptographic Functions Errors|FOCX0017]]</b> is raised if }} padding is incorrect.<br/><b>[[{{Error|FOCX0018|XQuery Errors#Cryptographic Functions Errors|FOCX0018]]</b> is raised if }} the encryption type is not supported.<br/><b>[[{{Error|FOCX0019|XQuery Errors#Cryptographic Functions Errors|FOCX0019]]</b> is raised if }} the secret key is invalid.<br/><b>[[{{Error|FOCX0020|XQuery Errors#Cryptographic Functions Errors|FOCX0020]]</b> is raised if }} the block size is incorrect.<br/><b>[[{{Error|FOCX0021|XQuery Errors#Cryptographic Functions Errors|FOCX0021]]</b> is raised if }} the specified encryption algorithm is not supported.<br/>
|-
| '''Example'''
| '''Summary'''
|Decrypts the encrypted {{Code|$input}}.<br/>
{{Code|$decryption-type}} must be {{Code|symmetric}}. An option for asymmetric encryption will most likely be added with another version of BaseX. <b>'''Default is {{Code|symmetric}}</b>'''.<br/>
{{Code|$secret-key}} is the secret key which is used for both encryption and decryption of input data. Its length is fixed and depends on the chosen algorithm: {{Code|8 bytes for DES}}, {{Code|16 bytes for AES}}.<br/>
{{Code|$cryptographic-algorithm}} must either be {{Code|DES}} or {{Code|AES}}. Other algorithms are not supported so far, but, of course, can be added on demand. <b>'''Default is {{Code|DES}}</b>'''.
|-
| '''Errors'''
|<b>[[{{Error|FOCX0016|XQuery Errors#Cryptographic Functions Errors|FOCX0016]]</b> is raised if }} padding problems arise.<br/><b>[[{{Error|FOCX0017|XQuery Errors#Cryptographic Functions Errors|FOCX0017]]</b> is raised if }} padding is incorrect.<br/><b>[[{{Error|FOCX0018|XQuery Errors#Cryptographic Functions Errors|FOCX0018]]</b> is raised if }} the encryption type is not supported.<br/><b>[[{{Error|FOCX0019|XQuery Errors#Cryptographic Functions Errors|FOCX0019]]</b> is raised if }} the secret key is invalid.<br/><b>[[{{Error|FOCX0020|XQuery Errors#Cryptographic Functions Errors|FOCX0020]]</b> is raised if }} the block size is incorrect.<br/><b>[[{{Error|FOCX0021|XQuery Errors#Cryptographic Functions Errors|FOCX0021]]</b> is raised if }} the specified encryption algorithm is not supported.<br/>
|-
| '''Example'''
|-
| '''Summary'''
|{{Code|$canonicalization-algorithm}} must either be {{Code|inclusive-with-comments}}, {{Code|inclusive}}, {{Code|exclusive-with-comments}} or {{Code|exclusive}}. <b>'''Default is {{Code|inclusive-with-comments}}</b>'''.<br/>{{Code|$digest-algorithm}} must be one of the following: {{Code|SHA1}}, {{Code|SHA256}} or {{Code|SHA512}}. <b>'''Default is {{Code|SHA1}}</b>'''.<br/>{{Code|$signature-algorithm}} must either be {{Code|RSA_SHA1}} or {{Code|DSA_SHA1}}. <b>'''Default is {{Code|RSA_SHA1}}</b>'''.<br/>
{{Code|$signature-namespace-prefix}} may be empty and prefixes the {{Code|Signature}} element accordingly.<br/>
{{Code|$signature-type}} must either be {{Code|enveloped}} or {{Code|enveloping}}. Detached signatures are so far not supported. <b>'''Default is {{Code|enveloped}}</b>'''.<br/>
{{Code|$xpath-expression}} is an arbitrary XPath expression which specifies a subset of the document that is to be signed.<br/>
{{Code|$digital-certificate}} is the digitial certificate used to sign the input document.
|-
| '''Errors'''
|<b>[[{{Error|FOCX0001|XQuery Errors#Cryptographic Functions Errors|FOCX0001]]</b> is raised if }} the canonicalization algorithm is not supported.<br/><b>[[{{Error|FOCX0002|XQuery Errors#Cryptographic Functions Errors|FOCX0002]]</b> is raised if }} the digest algorithm is not supported.<br/><b>[[{{Error|FOCX0003|XQuery Errors#Cryptographic Functions Errors|FOCX0003]]</b> is raised if }} the signature algorithm is not supported.<br/><b>[[{{Error|FOCX0004|XQuery Errors#Cryptographic Functions Errors|FOCX0004]]</b> is raised if }} the {{Code|$xpath-expression}} is invalid.<br/><b>[[{{Error|FOCX0005|XQuery Errors#Cryptographic Functions Errors|FOCX0005]]</b> is raised if }} the root name of {{Code|$digital-certificate}} is not 'digital-certificate.<br/><b>[[{{Error|FOCX0007|XQuery Errors#Cryptographic Functions Errors|FOCX0007]]</b> is raised if }} the key store is null.<br/><b>[[{{Error|FOCX0012|XQuery Errors#Cryptographic Functions Errors|FOCX0012]]</b> is raised if }} the key cannot be found in the specified key store.<br/><b>[[{{Error|FOCX0023|XQuery Errors#Cryptographic Functions Errors|FOCX0023]]</b> is raised if }} the certificate alias is invalid.<br/><b>[[{{Error|FOCX0024|XQuery Errors#Cryptographic Functions Errors|FOCX0024]]</b> is raised if }} an invalid algorithm is specified.<br/><b>[[{{Error|FOCX0025|XQuery Errors#Cryptographic Functions Errors|FOCX0025]]</b> is raised if }} an exception occurs while the signing the document.<br/><b>[[{{Error|FOCX0026|XQuery Errors#Cryptographic Functions Errors|FOCX0026]]</b> is raised if }} an exception occurs during key store initialization.<br/><b>[[{{Error|FOCX0027|XQuery Errors#Cryptographic Functions Errors|FOCX0027]]</b> is raised if }} an IO exception occurs.<br/><b>[[{{Error|FOCX0028|XQuery Errors#Cryptographic Functions Errors|FOCX0028]]</b> is raised if }} the signature type is not supported.<br/>
|-
| '''Example'''
|-
| '''Errors'''
|<b>[[{{Error|FOCX0015|XQuery Errors#Cryptographic Functions Errors|FOCX0015]]</b> is raised if }} the signature element cannot be found.<br/><b>[[{{Error|FOCX9994|XQuery Errors#Cryptographic Functions Errors|FOCX9994]]</b> is raised if }} an unspecified problem occurs during validation.<br/><b>[[{{Error|FOCX9996|XQuery Errors#Cryptographic Functions Errors|FOCX9996]]</b> is raised if }} an IO exception occurs during validation.<br/>
|-
| '''Example'''