Changes

Jump to navigation Jump to search
2,470 bytes added ,  20:25, 12 June 2012
Created page with "This XQuery Module contains cryptographic hash functions. =Conventions= All functions in this module are assigned to the {{Code|http://basex.org/modules/hash..."
This [[Module Library|XQuery Module]] contains cryptographic hash functions.

=Conventions=

All functions in this module are assigned to the {{Code|http://basex.org/modules/hash}} namespace, which is statically bound to the {{Code|hash}} prefix.<br/>
All errors are assigned to the {{Code|http://basex.org/errors}} namespace, which is statically bound to the {{Code|bxerr}} prefix.

=Functions=

==util:md5==
{|
|-
| width='90' | '''Signatures'''
|{{Func|util:md5|$value as xs:string|xs:hexBinary}}<br />
|-
| '''Summary'''
|Computes the MD5 hash of the given string {{Code|$value}}.<br />
|-
| '''Examples'''
|
* {{Code|util:md5("")}} returns {{Code|'D41D8CD98F00B204E9800998ECF8427E'}}.
* {{Code|util:md5('BaseX')}} returns {{Code|'0D65185C9E296311C0A2200179E479A2'}}.
|}

==util:sha1==
{|
|-
| width='90' | '''Signatures'''
|{{Func|util:sha1|$value as xs:string|xs:hexBinary}}<br />
|-
| '''Summary'''
|Computes the SHA-1 hash of the given string {{Code|$value}}.<br />
|-
| '''Examples'''
|
* {{Code|util:sha1("")}} returns {{Code|'DA39A3EE5E6B4B0D3255BFEF95601890AFD80709'}}.
* {{Code|util:sha1("BaseX")}} returns {{Code|'3AD5958F0F27D5AFFDCA2957560F121D0597A4ED'}}.
|}

==util:sha256==
{|
|-
| width='90' | '''Signatures'''
|{{Func|util:sha256|$value as xs:string|xs:hexBinary}}<br />
|-
| '''Summary'''
|Computes the SHA-256 hash of the given string {{Code|$value}}.<br />
|-
| '''Examples'''
|
* {{Code|util:sha256("")}} returns {{Code|'E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855'}}.
* {{Code|util:sha256("BaseX")}} returns {{Code|'15D570763DEB75D728BB69643392873B835CCCC94A2F1E881909DA47662821A3'}}.
|}

==util:hash==
{|
|-
| width='90' | '''Signatures'''
|{{Func|util:hash|$value as xs:string, $algorithm as xs:string|xs:hexBinary}}<br />
|-
| '''Summary'''
|Computes the hash of the given string {{Code|$value}}, using the specified {{Code|$algorithm}}.<br />The following three algorihms are supported: {{@Code|MD5}}, {{@Code|SHA-1}}, and {{@Code|SHA-256}}.
|-
| '''Errors'''
|{{Error|HASH0001|#Errors}} the specified hashing algorithm is unknown.
|-
| '''Examples'''
|{{Code|util:md5("", "MD5")}} returns {{Code|'D41D8CD98F00B204E9800998ECF8427E'}}.
{{Code|util:md5("", "")}} raises an error.
|}

=Errors=

{| class="wikitable" width="100%"
! width="5%"|Code
! width="95%"|Description
|-
|{{Code|HASH0001}}
|The specified hashing algorithm is unknown.
|}

=Changelog=

This module was introduced with Version 7.3.

[[Category:XQuery]]
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu