Qore Programming Language Reference Manual  1.12.0
Digest (Hash) Functions
Collaboration diagram for Digest (Hash) Functions:

Modules

 HMAC Functions
 

Functions

string Qore::DSS (data data)
 Returns the DSS message digest (based on SHA-0 and DSA) of the supplied argument as a hex string. More...
 
string Qore::DSS1 (data data)
 Returns the DSS1 message digest (based on SHA1 and DSA) of the supplied argument as a hex string. More...
 
binary Qore::DSS1_bin (data data)
 Returns the DSS1 message digest (based on SHA-0 and DSA) of the supplied argument as a binary value. More...
 
binary Qore::DSS_bin (data data)
 Returns the DSS message digest (based on SHA-0 and DSA) of the supplied argument as a binary value. More...
 
string Qore::MD2 (data data)
 Returns the MD2 message digest of the supplied argument as a hex string. More...
 
binary Qore::MD2_bin (data data)
 Returns the MD2 message digest of the supplied argument as binary value. More...
 
string Qore::MD4 (data data)
 Returns the MD4 message digest of the supplied argument as a hex string. More...
 
binary Qore::MD4_bin (data data)
 Returns the MD4 message digest of the supplied argument as a binary value. More...
 
string Qore::MD5 (data data)
 Returns the MD5 message digest of the supplied argument as a hex string. More...
 
binary Qore::MD5_bin (data data)
 Returns the MD5 message digest of the supplied argument as a binary value. More...
 
string Qore::MDC2 (data data)
 Returns the MDC2 message digest of the supplied argument as a hex string. More...
 
binary Qore::MDC2_bin (data data)
 Returns the MDC2 message digest of the supplied argument as a binary value. More...
 
string Qore::RIPEMD160 (data data)
 Returns the RIPEMD message digest of the supplied argument as a hex string. More...
 
binary Qore::RIPEMD160_binary (data data)
 Returns the RIPEMD message digest of the supplied argument as a binary value. More...
 
string Qore::SHA (data data)
 Returns the SHA (outdated SHA-0) message digest of the supplied argument as a hex string. More...
 
string Qore::SHA1 (data data)
 Returns the SHA1 message digest of the supplied argument as a hex string. More...
 
binary Qore::SHA1_bin (data data)
 Returns the SHA1 message digest of the supplied argument as a binary value. More...
 
string Qore::SHA224 (data data)
 Returns the SHA-224 message digest (a variant of SHA-2) of the supplied argument as a hex string. More...
 
binary Qore::SHA224_bin (data data)
 Returns the SHA-224 message digest (a variant of SHA-2) of the supplied argument as a binary value. More...
 
string Qore::SHA256 (data data)
 Returns the SHA-256 message digest (a variant of SHA-2) of the supplied argument as a hex string. More...
 
binary Qore::SHA256_bin (data data)
 Returns the SHA-256 message digest (a variant of SHA-2) of the supplied argument as a binary value. More...
 
string Qore::SHA384 (data data)
 Returns the SHA-384 message digest (a variant of SHA-2) of the supplied argument as a hex string. More...
 
binary Qore::SHA384_bin (data data)
 Returns the SHA-384 message digest (a variant of SHA-2) of the supplied argument as a binary value. More...
 
string Qore::SHA512 (data data)
 Returns the SHA-512 message digest (a variant of SHA-2) of the supplied argument as a hex string. More...
 
binary Qore::SHA512_bin (data data)
 Returns the SHA-512 message digest (a variant of SHA-2) of the supplied argument as a binary value. More...
 
binary Qore::SHA_bin (data data)
 Returns the SHA (outdated SHA-0) message digest of the supplied argument as a binary value. More...
 

Detailed Description

Qore's cryptography support is provided by the OpenSSL library.

A cryptographic hash function is a hash function; that is, an algorithm that takes an arbitrary block of data and returns a fixed-size bit string, the (cryptographic) hash value, such that any (accidental or intentional) change to the data will (with very high probability) change the hash value. The data to be encoded are often called the "message," and the hash value is sometimes called the message digest or simply digest.

For more info: Wikipedia's Cryptographic hash function article.

See also:

Function Documentation

◆ DSS()

string Qore::DSS ( data  data)

Returns the DSS message digest (based on SHA-0 and DSA) of the supplied argument as a hex string.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d")
Example:
string str = DSS("hello"); # returns "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
string DSS(data data)
Returns the DSS message digest (based on SHA-0 and DSA) of the supplied argument as a hex string.
Exceptions
DSS-DIGEST-ERRORerror calculating digest (should not normally happen)
See also
Note
this digest algorithm is considered outdated and is included for backwards-compatibility only when Qore is built with an older openssl library

◆ DSS1()

string Qore::DSS1 ( data  data)

Returns the DSS1 message digest (based on SHA1 and DSA) of the supplied argument as a hex string.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d")
Example:
string str = DSS1("hello"); # returns "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
string DSS1(data data)
Returns the DSS1 message digest (based on SHA1 and DSA) of the supplied argument as a hex string.
Exceptions
DSS1-DIGEST-ERRORerror calculating digest (should not normally happen)
See also
Note
this digest algorithm is considered outdated and is included for backwards-compatibility only when Qore is built with an older openssl library

◆ DSS1_bin()

binary Qore::DSS1_bin ( data  data)

Returns the DSS1 message digest (based on SHA-0 and DSA) of the supplied argument as a binary value.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = DSS1_bin("hello");
binary DSS1_bin(data data)
Returns the DSS1 message digest (based on SHA-0 and DSA) of the supplied argument as a binary value.
Exceptions
DSS1-DIGEST-ERRORerror calculating digest (should not normally happen)
See also
Note
this digest algorithm is considered outdated and is included for backwards-compatibility only when Qore is built with an older openssl library

◆ DSS_bin()

binary Qore::DSS_bin ( data  data)

Returns the DSS message digest (based on SHA-0 and DSA) of the supplied argument as a binary value.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = DSS_bin("hello");
binary DSS_bin(data data)
Returns the DSS message digest (based on SHA-0 and DSA) of the supplied argument as a binary value.
Exceptions
DSS-DIGEST-ERRORerror calculating digest (should not normally happen)
See also
Note
this digest algorithm is considered outdated and is included for backwards-compatibility only when Qore is built with an older openssl library

◆ MD2()

string Qore::MD2 ( data  data)

Returns the MD2 message digest of the supplied argument as a hex string.

Platform Availability:
Qore::Option::HAVE_MD2
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "a9046c73e00331af68917d3804f70655")
Example:
string str = MD2("hello"); # returns "a9046c73e00331af68917d3804f70655"
string MD2(data data)
Returns the MD2 message digest of the supplied argument as a hex string.
Exceptions
MD2-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ MD2_bin()

binary Qore::MD2_bin ( data  data)

Returns the MD2 message digest of the supplied argument as binary value.

Platform Availability:
Qore::Option::HAVE_MD2
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = MD2_bin("hello");
binary MD2_bin(data data)
Returns the MD2 message digest of the supplied argument as binary value.
Exceptions
MD2-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ MD4()

string Qore::MD4 ( data  data)

Returns the MD4 message digest of the supplied argument as a hex string.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "866437cb7a794bce2b727acc0362ee27")
Example:
string str = MD4("hello"); # returns "866437cb7a794bce2b727acc0362ee27"
string MD4(data data)
Returns the MD4 message digest of the supplied argument as a hex string.
Exceptions
MD4-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ MD4_bin()

binary Qore::MD4_bin ( data  data)

Returns the MD4 message digest of the supplied argument as a binary value.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = MD4_bin("hello");
binary MD4_bin(data data)
Returns the MD4 message digest of the supplied argument as a binary value.
Exceptions
MD4-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ MD5()

string Qore::MD5 ( data  data)

Returns the MD5 message digest of the supplied argument as a hex string.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "5d41402abc4b2a76b9719d911017c592")
Example:
string str = MD5("hello"); # returns "5d41402abc4b2a76b9719d911017c592"
string MD5(data data)
Returns the MD5 message digest of the supplied argument as a hex string.
Exceptions
MD5-DIGEST-ERRORerror calculating digest (should not normally happen)
Note
  • equivalent to <string>::toMD5()
  • the MD5 algorithm is not collision-resistant; it's recommended to use another hash algorithm (like SHA-256) if cryptographic security is important
See also

◆ MD5_bin()

binary Qore::MD5_bin ( data  data)

Returns the MD5 message digest of the supplied argument as a binary value.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = MD5_bin("hello");
binary MD5_bin(data data)
Returns the MD5 message digest of the supplied argument as a binary value.
Exceptions
MD5-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ MDC2()

string Qore::MDC2 ( data  data)

Returns the MDC2 message digest of the supplied argument as a hex string.

Platform Availability:
Qore::Option::HAVE_MDC2
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "4517036cf97b2407d6fe22aa5ab878a3")
Example:
string str = MDC2("hello"); # returns "4517036cf97b2407d6fe22aa5ab878a3"
string MDC2(data data)
Returns the MDC2 message digest of the supplied argument as a hex string.
Exceptions
MDC2-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ MDC2_bin()

binary Qore::MDC2_bin ( data  data)

Returns the MDC2 message digest of the supplied argument as a binary value.

Platform Availability:
Qore::Option::HAVE_MDC2
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = MDC2_bin("hello");
binary MDC2_bin(data data)
Returns the MDC2 message digest of the supplied argument as a binary value.
Exceptions
MDC2-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ RIPEMD160()

string Qore::RIPEMD160 ( data  data)

Returns the RIPEMD message digest of the supplied argument as a hex string.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "108f07b8382412612c048d07d13f814118445acd")
Example:
string str = RIPEMD160("hello"); # returns "108f07b8382412612c048d07d13f814118445acd"
string RIPEMD160(data data)
Returns the RIPEMD message digest of the supplied argument as a hex string.
Exceptions
RIPEMD160-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ RIPEMD160_binary()

binary Qore::RIPEMD160_binary ( data  data)

Returns the RIPEMD message digest of the supplied argument as a binary value.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = RIPEMD160_bin("hello");
Exceptions
RIPEMD160-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ SHA()

string Qore::SHA ( data  data)

Returns the SHA (outdated SHA-0) message digest of the supplied argument as a hex string.

This hash algorithm was withdrawn after publishing and is considered to have serious flaws.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "ac62a630ca850b4ea07eda664eaecf9480843152")
Example:
string str = SHA("hello"); returns "ac62a630ca850b4ea07eda664eaecf9480843152"
string SHA(data data)
Returns the SHA (outdated SHA-0) message digest of the supplied argument as a hex string.
Exceptions
SHA-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ SHA1()

string Qore::SHA1 ( data  data)

Returns the SHA1 message digest of the supplied argument as a hex string.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d")
Example:
string str = SHA1("hello"); # "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
string SHA1(data data)
Returns the SHA1 message digest of the supplied argument as a hex string.
Exceptions
SHA1-DIGEST-ERRORerror calculating digest (should not normally happen)
Note
equivalent to <string>::toSHA1()
See also

◆ SHA1_bin()

binary Qore::SHA1_bin ( data  data)

Returns the SHA1 message digest of the supplied argument as a binary value.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = SHA1_bin("hello");
binary SHA1_bin(data data)
Returns the SHA1 message digest of the supplied argument as a binary value.
Exceptions
SHA1-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ SHA224()

string Qore::SHA224 ( data  data)

Returns the SHA-224 message digest (a variant of SHA-2) of the supplied argument as a hex string.

Platform Availability:
Qore::Option::HAVE_SHA224
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "ea09ae9cc6768c50fcee903ed054556e5bfc8347907f12598aa24193")
Example:
string str = SHA224("hello"); # returns "ea09ae9cc6768c50fcee903ed054556e5bfc8347907f12598aa24193"
string SHA224(data data)
Returns the SHA-224 message digest (a variant of SHA-2) of the supplied argument as a hex string.
Exceptions
SHA224-DIGEST-ERRORerror calculating digest (should not normally happen)
Note
equivalent to <string>::toSHA224()
See also

◆ SHA224_bin()

binary Qore::SHA224_bin ( data  data)

Returns the SHA-224 message digest (a variant of SHA-2) of the supplied argument as a binary value.

Platform Availability:
Qore::Option::HAVE_SHA224
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = SHA224_bin("hello");
binary SHA224_bin(data data)
Returns the SHA-224 message digest (a variant of SHA-2) of the supplied argument as a binary value.
Exceptions
SHA224-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ SHA256()

string Qore::SHA256 ( data  data)

Returns the SHA-256 message digest (a variant of SHA-2) of the supplied argument as a hex string.

Platform Availability:
Qore::Option::HAVE_SHA256
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824")
Example:
string str = SHA256("hello"); # returns "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
string SHA256(data data)
Returns the SHA-256 message digest (a variant of SHA-2) of the supplied argument as a hex string.
Exceptions
SHA256-DIGEST-ERRORerror calculating digest (should not normally happen)
Note
equivalent to <string>::toSHA256()
See also

◆ SHA256_bin()

binary Qore::SHA256_bin ( data  data)

Returns the SHA-256 message digest (a variant of SHA-2) of the supplied argument as a binary value.

Platform Availability:
Qore::Option::HAVE_SHA256
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = SHA256_bin("hello");
binary SHA256_bin(data data)
Returns the SHA-256 message digest (a variant of SHA-2) of the supplied argument as a binary value.
Exceptions
SHA256-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ SHA384()

string Qore::SHA384 ( data  data)

Returns the SHA-384 message digest (a variant of SHA-2) of the supplied argument as a hex string.

Platform Availability:
Qore::Option::HAVE_SHA384
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f")
Example:
string str = SHA384("hello"); # returns "59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f"
string SHA384(data data)
Returns the SHA-384 message digest (a variant of SHA-2) of the supplied argument as a hex string.
Exceptions
SHA384-DIGEST-ERRORerror calculating digest (should not normally happen)
Note
equivalent to <string>::toSHA384()
See also

◆ SHA384_bin()

binary Qore::SHA384_bin ( data  data)

Returns the SHA-384 message digest (a variant of SHA-2) of the supplied argument as a binary value.

Platform Availability:
Qore::Option::HAVE_SHA384
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = SHA384_bin("hello");
binary SHA384_bin(data data)
Returns the SHA-384 message digest (a variant of SHA-2) of the supplied argument as a binary value.
Exceptions
SHA384-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ SHA512()

string Qore::SHA512 ( data  data)

Returns the SHA-512 message digest (a variant of SHA-2) of the supplied argument as a hex string.

Platform Availability:
Qore::Option::HAVE_SHA512
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a hex string of the digest (ex: "9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043")
Example:
string str = SHA512("hello"); # returns "9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043"
string SHA512(data data)
Returns the SHA-512 message digest (a variant of SHA-2) of the supplied argument as a hex string.
Exceptions
SHA512-DIGEST-ERRORerror calculating digest (should not normally happen)
Note
equivalent to <string>::toSHA512()
See also

◆ SHA512_bin()

binary Qore::SHA512_bin ( data  data)

Returns the SHA-512 message digest (a variant of SHA-2) of the supplied argument as a binary value.

Platform Availability:
Qore::Option::HAVE_SHA512
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = SHA512_bin("hello");
binary SHA512_bin(data data)
Returns the SHA-512 message digest (a variant of SHA-2) of the supplied argument as a binary value.
Exceptions
SHA512-DIGEST-ERRORerror calculating digest (should not normally happen)
See also

◆ SHA_bin()

binary Qore::SHA_bin ( data  data)

Returns the SHA (outdated SHA-0) message digest of the supplied argument as a binary value.

This hash algorithm was withdrawn after publishing and is considered to have serious flaws.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments
Returns
a binary value of the digest
Example:
binary bin = SHA_bin("hello");
binary SHA_bin(data data)
Returns the SHA (outdated SHA-0) message digest of the supplied argument as a binary value.
Exceptions
SHA-DIGEST-ERRORerror calculating digest (should not normally happen)
See also