Changes

Jump to navigation Jump to search
56 bytes removed ,  19:01, 23 September 2019
|Creates an authentication code for the specified {{Code|$data}} via a cryptographic hash function:
* {{Code|$key}} must not be empty.
* {{Code|$algorithm}} describes the hash algorithm which is used for encryption. Currently supported are {{Code|md5}}, {{Code|sha1}}, {{Code|sha256}}, {{Code|sha384}}, {{Code|sha512}}. '''Default is {{Code|md5}}'''.* {{Code|$encoding}} must either be {{Code|hex}} or {{Code|base64}}; it specifies the encoding of the returned authentication code. '''Default is {{Code|base64}}'''.
|-
| '''Errors'''
|-
| '''Example'''
|'''Returns the Return message authentication code (MAC) for a given string.''':
'''Query:'''
<pre class="brush:xquery">
crypto:hmac('message','secretkey','md5','base64hex')
</pre>
The encryption and decryption functions underlie several limitations:
* Cryptographic algorithms are currently limited to {{Code|symmetric}} algorithms. This means that the same secret key is used for encryption and decryption.
* Available algorithms are {{Code|desDES}} and {{Code|aesAES}}.
* Padding is fixed to {{Code|PKCS5Padding}}.
* The result of an encryption using the same message, algorithm and key looks different each time it is executed. This is due to a random initialization vector (IV) which is appended to the message and simply increases security.
* {{Code|$data}} must be a string or binary item.
* {{Code|$type}} must be {{Code|symmetric}}.
* {{Code|$key}} is the secret key which is used for both encryption and decryption of input data. It must be a string or binary item. Its length is fixed and depends on the chosen algorithm: 8 bytes for {{Code|desDES}}, 16 bytes for {{Code|aesAES}}.* {{Code|$algorithm}} must either be {{Code|desDES}} or {{Code|aesAES}}. Default is {{Code|desDES}}.
|-
| '''Errors'''
|-
| '''Example'''
|'''Encrypts Encrypt input data.''' '''Query:'''
<pre class="brush:xquery">
crypto:encrypt('message', 'symmetric','keykeyke','DES')
</pre>
|}
* {{Code|$data}} must be a string or binary item.
* {{Code|$type}} must be {{Code|symmetric}}.
* {{Code|$key}} is the secret key which is used for both encryption and decryption of input data. It must be a string or binary item. Its length is fixed and depends on the chosen algorithm: 8 bytes for {{Code|DES}}, 16 bytes for {{Code|aesAES}}.* {{Code|$algorithm}} must either be {{Code|DES}} or {{Code|aesAES}}. Default is {{Code|DES}}.
|-
| '''Errors'''
|-
| '''Example'''
|'''Decrypts Decrypt input data and returns the return original string.''':
'''Query:'''
<pre class="brush:xquery">
let $encrypted := crypto:encrypt('message', 'symmetric', 'keykeyke', 'desDES')return crypto:decrypt($encrypted, 'symmetric', 'keykeyke', 'desDES')
</pre>
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu