=Conventions=
All functions and errors in this module are assigned to the <code><nowiki>http://basex.org/modules/hash</nowiki></code> namespace, which is statically bound to the {{Code|hash}} prefix.<br/>All errors are assigned to the <code><nowiki>http://basex.org/errors</nowiki></code> namespace, which is statically bound to the {{Code|bxerr}} prefix.
=Functions=
==hash:md5==
{| width='100%'
|-valign="top"| width='120' | '''SignaturesSignature'''|{{Func|<pre>hash:md5|( $value as xs:anyAtomicType|) as xs:base64Binary}}<br /pre>|-valign="top"
| '''Summary'''
|Computes the MD5 hash of the given {{Code|$value}}, which may be of type {{Code|xs:string}}, {{Code|xs:base64Binary}}, or {{Code|xs:hexBinary}}.|-valign="top"
| '''Examples'''
|
==hash:sha1==
{| width='100%'
|-valign="top"| width='120' | '''SignaturesSignature'''|{{Func|<pre>hash:sha1|( $value as xs:anyAtomicType|) as xs:base64Binary}}<br /pre>|-valign="top"
| '''Summary'''
|Computes the SHA-1 hash of the given {{Code|$value}}, which may be of type {{Code|xs:string}}, {{Code|xs:base64Binary}}, or {{Code|xs:hexBinary}}.|-valign="top"
| '''Examples'''
|
==hash:sha256==
{| width='100%'
|-valign="top"| width='120' | '''SignaturesSignature'''|{{Func|<pre>hash:sha256|( $value as xs:anyAtomicType|) as xs:base64Binary}}<br /pre>|-valign="top"
| '''Summary'''
|Computes the SHA-256 hash of the given {{Code|$value}}, which may be of type {{Code|xs:string}}, {{Code|xs:base64Binary}}, or {{Code|xs:hexBinary}}.|-valign="top"
| '''Examples'''
|
==hash:hash==
{| width='100%'
|-valign="top"| width='120' | '''SignaturesSignature'''|{{Func|<pre>hash:hash|( $value as xs:anyAtomicType, $algorithm as xs:string|) as xs:base64Binary}}<br /pre>|-valign="top"
| '''Summary'''
|Computes the hash of the given {{Code|$value}}, using the specified {{Code|$algorithm}}. The specified values may be of type {{Code|xs:string}}, {{Code|xs:base64Binary}}, or {{Code|xs:hexBinary}}.<br />The following three algorihms algorithms are supported: {{Code|MD5}}, {{Code|SHA-1}}, and {{Code|SHA-256}}.|-valign="top"
| '''Errors'''
|{{Error|HASH0001algorithm|#Errors}} the specified hashing algorithm is unknown.|-valign="top"
| '''Examples'''
|
* {{Code|string(xs:hexBinary(hash:hash("", "MD5")))}} returns {{Code|D41D8CD98F00B204E9800998ECF8427E}}.
* {{Code|string(hash:hash("", ""))}} raises an error, because no algorithm was specified.
|}
! width="110"|Code
|Description
|-valign="top"|{{Code|HASH0001algorithm}}
|The specified hash algorithm is unknown.
|}
=Changelog=
;Version 9.0
* Updated: error codes updated; errors now use the module namespace
The module was introduced with Version 7.3.