Go to main content

hash

Calculate the hash of a string.

HASH

NAME

hash - Calculates the hash of a string.

SYNOPSIS

md5([algo:"md5|md4|md2|sha256|sha384|sha512"],strings…)

DESCRIPTION

This statement is used to compute the digest of a list of strings. 

PARAMETERS

strings
The input strings.
algo
The algorithm to use. By default, it is set to md5. Only one algo can be specified.

RETURN

Returns the hash as a 32-character hexadecimal number.

EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

res={_{hash("pierre")==md5("pierre");}}. return res=true.

res={_{hash("pierre","laplante")==md5("pierrelaplante");}}. return res=true.

res={_{hash(algo:"md5","pierre","laplante")==md5("pierrelaplante");}}. return res=true.

res={_{hash(algo:"md4","Wikipedia, l'encyclopedie libre et gratuite")=="b94e66e0817dd34dc7858a0c131d4079";}}. return res=true.

res={_{hash(algo:"sha1","Wikipedia, l'encyclopedie libre et gratuite")=="afba34a2a11ab13eeba5d0a7aa22bbb6120e177b";}}. return res=true.

res={_{hash(algo:"md2","Wikipedia, l'encyclopedie libre et gratuite")=="c9b3cbbeb539034aac22567fa975f98e";}}. return res=true.

res={_{hash(algo:"sha256","Wikipedia, l'encyclopedie libre et gratuite")==
"26e6a5869428afd4393ce9edff2fe70ec37725d2d81612e64fc9ce8effbf9a75";}}. return res=true.

res={_{hash(algo:"sha512","Wikipedia, l'encyclopedie libre et gratuite")==
"73585d7c393cc548cfd6c4774a62f49c20bf16585a08a1e276f84fe3523538da12b61742f059ab56b05905eab6bab94b22b8b576ca7f5d8b612b2959083b84f3";}}. return res=true.

res={_{hash(algo:"sha384","Wikipedia, l'encyclopedie libre et gratuite")==
"cda113c0c525d008285f8027936303d9f90e9c26553f267b451e8b695598f54cef65f6826b25d48bb428289c8fb5e736";}}. return res=true.

res={_{hash(algo:"asha384","Wikipedia, l'encyclopedie libre et gratuite");}}. return Invalid hash function: asha384

SEE ALSO

{{ include("includes/strings.sn") }}

AUTHOR

Written by Pusnei Sergey and Caroline Laplante, <sergey@sednove.com>

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.