Link Search Menu Expand Document

hash

This module provides a framework for cryptographic and non-cryptographic encryption.

Examples,

%> import hash
%> 
%> hash.md5('Hello, World')
'82bb413746aee42f89dea2b59614f9ef'
%> 
%> hash.sha256('Hello, World')
'03675ac53ff9cd1535ccc7dfcdfa2c458c5218371f418dc136f2d19ac1fbe8a5'
%> 
%> hash.siphash('mykey', 'Hello, World')
'd8e830a590c92b4c'
%> 
%> hash.hmac_sha256('mykey', 'Hello, World')
'61035d3d2119ffdfd710913bf4161d5fba1c2d9431f7de7ef398d359eb1d2481'
%> 
%> hash.hmac_sha256(bytes([10, 11, 12]), 'My secure text!')
'd782079145a3476fd4e018d44dd024034fa91f626f7f30f2009200c5ac757723'

Functions


hash.hash(value: any)
returns the hash of a value as used in a dictionary underlying implementation.

a class may override the result of this function by implementing the hash decorator

return number
hash.adler32(str: string | bytes, [value: number])
returns the adler32 value of the given string or bytes

if value is given, it is used as the base value of the adler32 computation. Else, 1 is used.

return number
hash.crc32(str: string | bytes, [value: number])
returns the crc32 value of the given string or bytes

if value is given, it is used as the base value of the crc32 computation. Else, 0 is used.

return number
hash.md2(str: string | bytes)
returns the md2 hash of the given string or bytes
return string
hash.md4(str: string | bytes)
returns the md4 hash of the given string or bytes
return string
hash.md5(str: string | bytes)
returns the md5 hash of the given string or bytes
return string
hash.**md5file**(_str: file)
returns the md5 hash of the given file
return string
hash.sha1(str: string | bytes)
returns the sha1 hash of the given string or bytes
return string
hash.sha224(str: string | bytes)
returns the sha224 hash of the given string or bytes
return string
hash.sha256(str: string | bytes)
returns the sha256 hash of the given string or bytes
return string
hash.sha384(str: string | bytes)
returns the sha384 hash of the given string or bytes
return string
hash.sha512(str: string | bytes)
returns the sha512 hash of the given string or bytes
return string
hash.fnv1(str: string | bytes)
returns the 32 bit fnv1 hash of the given string or bytes
return string
hash.**fnv164**(_str: string | bytes)
returns the 64 bit fnv1 hash of the given string or bytes
return string
hash.fnv1a(str: string | bytes)
returns the 32 bit fnv1a hash of the given string or bytes
return string
hash.fnv1a_64(str: string | bytes)
returns the 64 bit fnv1a hash of the given string or bytes
return string
hash.whirlpool(str: string | bytes)
returns the whirlpool hash of the given string or bytes
return string
hash.snefru(str: string | bytes)
returns the snefru cyrptographic hash of the given string or bytes
return string
hash.siphash(key: string | bytes, str: string | bytes)
returns the siphash cyrptographic hash of the given string or bytes
return string
hash.gost(str: string | bytes)
returns the gost cyrptographic hash of the given string or bytes
return string
hash.hmac(method: function, key: string | bytes, str: string | bytes)
computes an HMAC with the key and str using the given method
return string
hash.hmac_md2(key: string | bytes, str: string | bytes)
returns the HMAC-MD2 cyrptographic hash of the given string or bytes
return string
hash.hmac_md4(key: string | bytes, str: string | bytes)
returns the HMAC-MD4 cyrptographic hash of the given string or bytes
return string
hash.hmac_md5(key: string | bytes, str: string | bytes)
returns the HMAC-MD5 cyrptographic hash of the given string or bytes
return string
hash.hmac_sha1(key: string | bytes, str: string | bytes)
returns the HMAC-SHA1 cyrptographic hash of the given string or bytes
return string
hash.hmac_sha224(key: string | bytes, str: string | bytes)
returns the HMAC-SHA224 cyrptographic hash of the given string or bytes
return string
hash.hmac_sha256(key: string | bytes, str: string | bytes)
returns the HMAC-SHA256 cyrptographic hash of the given string or bytes
return string
hash.hmac_sha384(key: string | bytes, str: string | bytes)
returns the HMAC-SHA384 cyrptographic hash of the given string or bytes
return string
hash.hmac_sha512(key: string | bytes, str: string | bytes)
returns the HMAC-SHA512 cyrptographic hash of the given string or bytes
return string
hash.hmac_whirlpool(key: string | bytes, str: string | bytes)
returns the HMAC-WHIRLPOOL cyrptographic hash of the given string or bytes
return string
hash.hmac_snefru(key: string | bytes, str: string | bytes)
returns the HMAC-SNEFRU cyrptographic hash of the given string or bytes
return string
hash.hmac_gost(key: string | bytes, str: string | bytes)
returns the HMAC-GOST cyrptographic hash of the given string or bytes
return string

Back to top

Copyright © 2021 Ore Richard Muyiwa. Distributed under the MIT license.