{{newin|[[11.0]]|110|type=function}}
Compute the message digest of a string using a specified hash algorithm.
{{notice|There's [https://bitbucket.org/rude/love/issues/1453 bug] in version, up to [[11.2]] which gives wrong result for very-specific input length (112 + 128n for SHA512 and SHA384, 56 + 64n for other hash functions).}}
== Function ==
=== Synopsis ===
<source lang="lua">rawdigest = love.data.hash( hashFunction, string )</source>
=== Arguments ===
{{param|HashFunction|hashFunction|Hash algorithm to use.}}
{{param|string|string|String to hash.}}
=== Returns ===
{{param|string|rawdigest|Raw message digest string.}}
== Function ==
=== Synopsis ===
<source lang="lua">rawdigest = love.data.hash( hashFunction, data )</source>
=== Arguments ===
{{param|HashFunction|hashFunction|Hash algorithm to use.}}
{{param|Data|data|Data to hash.}}
=== Returns ===
{{param|string|rawdigest|Raw message digest string.}}
== Notes ==
To return the hex string representation of the hash, use [[love.data.encode]]
<source lang="lua">
hexDigestString = love.data.encode("string", "hex", love.data.hash(algo, data))
</source>
== See Also ==
* [[parent::love.data]]
* [[love.data.encode]]
* [[HashFunction]]
[[Category:Functions]]
{{#set:Description=Compute message digest using specific hash algorithm.}}
== Other Languages ==
{{i18n|love.data.hash}}