3.9. Digest Functions

3.9.1. DSS()

Synopsis

Returns the DSS message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a string of hex characters.

Usage
DSS(string | binary)
Example
$str = DSS("hello"); # returns "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"

Table 3.204. Arguments and Return Values for DSS()

Argument Type

Return Type

Description

String | Binary

String

Returns the DSS message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.205. Exceptions thrown by DSS()

err

desc

DSS-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.2. DSS_bin()

Synopsis

Returns the DSS message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a binary object.

Usage
DSS_bin(string | binary)
Example
$bin = DSS_bin("hello"); # returns <aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d>

Table 3.206. Arguments and Return Values for DSS_bin()

Argument Type

Return Type

Description

String | Binary

Binary

Returns the DSS message digest of the supplied argument (for strings, the trailing null character is not included in the digest).


Table 3.207. Exceptions thrown by DSS_bin()

err

desc

DSS-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.3. DSS1()

Synopsis

Returns the DSS1 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a hex string.

Usage
DSS1(string | binary)
Example
$str = DSS1("hello"); # return "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"

Table 3.208. Arguments and Return Values for DSS1()

Argument Type

Return Type

Description

String | Binary

String

The DSS1 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)


Table 3.209. Exceptions thrown by DSS1()

err

desc

DSS1-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.4. DSS1_bin()

Synopsis

Returns the DSS1 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a binary object.

Usage
DSS1_bin(string | binary)
Example
$bin = DSS1_bin("hello"); # returns <aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d>

Table 3.210. Arguments and Return Values for DSS1_bin()

Argument Type

Return Type

Description

String | Binary

Binary

The DSS1 message digest of the supplied argument (for strings, the trailing null character is not included in the digest).


Table 3.211. Exceptions thrown by DSS1()

err

desc

DSS1-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.5. MD2()

Synopsis

Returns the MD2 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a string of hex digits.

Usage
MD2(string | binary)
Example
$str = MD2("hello"); # returns "a9046c73e00331af68917d3804f70655"

Table 3.212. Arguments and Return Values for MD2()

Argument Type

Return Type

Description

String | Binary

String

The MD2 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.213. Exceptions thrown by MD2()

err

desc

MD2-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.6. MD2_bin()

Synopsis

Returns the MD2 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a string of hex digits.

Usage
MD2_bin(string | binary)
Example
$bin = MD2_bin("hello"); # returns <a9046c73e00331af68917d3804f70655>

Table 3.214. Arguments and Return Values for MD2_bin()

Argument Type

Return Type

Description

String | Binary

Binary

The MD2 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.215. Exceptions thrown by MD2_bin()

err

desc

MD2-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.7. MD4()

Synopsis

Returns the MD4 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a string of hex characters.

Usage
MD4(string | binary)
Example
$str = MD4("hello"); # returns "866437cb7a794bce2b727acc0362ee27"

Table 3.216. Arguments and Return Values for MD4()

Argument Type

Return Type

Description

String | Binary

String

The MD4 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.217. Exceptions thrown by MD4()

err

desc

MD4-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.8. MD4_bin()

Synopsis

Returns the MD4 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a string of hex characters.

Usage
MD4_bin(string | binary)
Example
$str = MD4_bin("hello"); # returns "866437cb7a794bce2b727acc0362ee27"

Table 3.218. Arguments and Return Values for MD4_bin()

Argument Type

Return Type

Description

String | Binary

Binary

The MD4 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a binary object


Table 3.219. Exceptions thrown by MD4_bin()

err

desc

MD4-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.9. MD5()

Synopsis

Returns the MD5 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a string of hex characters.

Usage
MD5(string | binary)
Example
$str = MD5("hello"); # returns "5d41402abc4b2a76b9719d911017c592"

Table 3.220. Arguments and Return Values for MD5()

Argument Type

Return Type

Description

String | Binary

String

The MD5 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a string of hext characters.


Table 3.221. Exceptions thrown by MD5()

err

desc

MD5-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.10. MD5_bin()

Synopsis

Returns the MD5 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a binary object.

Usage
MD5_bin(string | binary)
Example
$str = MD5_bin("hello"); # returns <5d41402abc4b2a76b9719d911017c592>

Table 3.222. Arguments and Return Values for MD5_bin()

Argument Type

Return Type

Description

String | Binary

Binary

The MD5 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a binary object.


Table 3.223. Exceptions thrown by MD5_bin()

err

desc

MD5-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.11. MDC2()

Synopsis

Returns the MDC2 message digest of the supplied argument (for strings, the trailing null character is not included in the digest). The availability of this function depends on the availability of the MDC2 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_MDC2 before running this function. See Library Option Constants for a list of all option constants.

Usage
MDC2(string | binary)
Example
$str = MDC2("hello");

Table 3.224. Arguments and Return Values for MDC2()

Argument Type

Return Type

Description

String | Binary

String

Returns the MDC2 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.225. Exceptions thrown by MDC2()

err

desc

MDC2-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_MDC2 before calling this function.


3.9.12. MDC2_bin()

Synopsis

Returns the MDC2 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a binary object. The availability of this function depends on the availability of the MDC2 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_MDC2 before running this function. See Library Option Constants for a list of all option constants.

Usage
MDC2_bin(string | binary)
Example
$bin = MDC2_bin("hello");

Table 3.226. Arguments and Return Values for MDC2_bin()

Argument Type

Return Type

Description

String | Binary

Binary

Returns the MDC2 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.227. Exceptions thrown by MDC2_bin()

err

desc

MDC2-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_MDC2 before calling this function.


3.9.13. RIPEMD160()

Synopsis

Returns the RIPEMD160 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a string of hex characters.

Usage
RIPEMD160(string | binary)
Example
$str = RIPEMD160("hello"); # returns "108f07b8382412612c048d07d13f814118445acd"

Table 3.228. Arguments and Return Values for RIPEMD160()

Argument Type

Return Type

Description

String | Binary

String

Returns the RIPEMD160 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.229. Exceptions thrown by RIPEMD160()

err

desc

RIPEMD160-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.14. RIPEMD160_bin()

Synopsis

Returns the RIPEMD160 message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a binary object.

Usage
RIPEMD160_bin(string | binary)
Example
$str = RIPEMD160_bin("hello"); # returns "108f07b8382412612c048d07d13f814118445acd"

Table 3.230. Arguments and Return Values for RIPEMD160_bin()

Argument Type

Return Type

Description

String | Binary

Binary

Returns the RIPEMD160 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.231. Exceptions thrown by RIPEMD160_bin()

err

desc

RIPEMD160-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.15. SHA()

Synopsis

Returns the SHA message digest of the supplied argument (for strings, the trailing null character is not included in the digest) as a string of hext characters.

Usage
SHA(string | binary)
Example
$str = SHA("hello"); returns "ac62a630ca850b4ea07eda664eaecf9480843152"

Table 3.232. Arguments and Return Values for SHA()

Argument Type

Return Type

Description

String | Binary

String

Returns the SHA message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.233. Exceptions thrown by SHA()

err

desc

SHA-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.16. SHA_bin()

Synopsis

Returns the SHA message digest of the supplied argument (for strings, the trailing null character is not included in the digest)

Usage
SHA_bin(string | binary)
Example
$bin = SHA_bin("hello"); returns <ac62a630ca850b4ea07eda664eaecf9480843152>

Table 3.234. Arguments and Return Values for SHA_bin()

Argument Type

Return Type

Description

String | Binary

Binary

Returns the SHA message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.235. Exceptions thrown by SHA_bin()

err

desc

SHA-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.17. SHA1()

Synopsis

Returns the SHA1 message digest of the supplied argument as a string of hex characters. For string arguments, the trailing null character is not included in the digest.

Usage
SHA1(string | binary)
Example
$str = SHA1("hello"); # "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"

Table 3.236. Arguments and Return Values for SHA1()

Argument Type

Return Type

Description

String | Binary

String

Returns the SHA1 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.237. Exceptions thrown by SHA1()

err

desc

SHA1-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.18. SHA1_bin()

Synopsis

Returns the SHA1 message digest of the supplied argument as a string of hex characters. For string arguments, the trailing null character is not included in the digest.

Usage
SHA1_bin(string | binary)
Example
$bin = SHA1_bin("hello"); # <aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d>

Table 3.238. Arguments and Return Values for SHA1_bin()

Argument Type

Return Type

Description

String | Binary

String

Returns the SHA1 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.239. Exceptions thrown by SHA1_bin()

err

desc

SHA1-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest


3.9.19. SHA224()

Synopsis

Returns the SHA224 message digest of the supplied argument as a string of hex characters. For string arguments, the trailing null character is not included in the digest. The availability of this function depends on the availability of the SHA224 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_SHA224 before running this function. See Library Option Constants for a list of all option constants.

Usage
SHA224(string | binary)
Example
$str = SHA224("hello"); # "ea09ae9cc6768c50fcee903ed054556e5bfc8347907f12598aa24193"

Table 3.240. Arguments and Return Values for SHA224()

Argument Type

Return Type

Description

String | Binary

String

Returns the SHA224 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.241. Exceptions thrown by SHA224()

err

desc

SHA224-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_SHA224 before calling this function.


3.9.20. SHA224_bin()

Synopsis

Returns the SHA224 message digest of the supplied argument as a string of hex characters. For string arguments, the trailing null character is not included in the digest. The availability of this function depends on the availability of the SHA224 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_SHA224 before running this function. See Library Option Constants for a list of all option constants.

Usage
SHA224_bin(string | binary)
Example
$bin = SHA224_bin("hello"); # <ea09ae9cc6768c50fcee903ed054556e5bfc8347907f12598aa24193>

Table 3.242. Arguments and Return Values for SHA224_bin()

Argument Type

Return Type

Description

String | Binary

String

Returns the SHA224 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.243. Exceptions thrown by SHA224_bin()

err

desc

SHA224-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_SHA224 before calling this function.


3.9.21. SHA256()

Synopsis

Returns the SHA256 message digest of the supplied argument as a string of hex characters. For string arguments, the trailing null character is not included in the digest. The availability of this function depends on the availability of the SHA256 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_SHA256 before running this function. See Library Option Constants for a list of all option constants.

Usage
SHA256(string | binary)
Example
$str = SHA256("hello"); # "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"

Table 3.244. Arguments and Return Values for SHA256()

Argument Type

Return Type

Description

String | Binary

String

Returns the SHA256 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.245. Exceptions thrown by SHA256()

err

desc

SHA256-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_SHA256 before calling this function.


3.9.22. SHA256_bin()

Synopsis

Returns the SHA256 message digest of the supplied argument as a string of hex characters. For string arguments, the trailing null character is not included in the digest. The availability of this function depends on the availability of the SHA256 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_SHA256 before running this function. See Library Option Constants for a list of all option constants.

Usage
SHA256_bin(string | binary)
Example
$bin = SHA256_bin("hello"); # <2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824>

Table 3.246. Arguments and Return Values for SHA256_bin()

Argument Type

Return Type

Description

String | Binary

String

Returns the SHA256 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.247. Exceptions thrown by SHA256_bin()

err

desc

SHA256-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_SHA256 before calling this function.


3.9.23. SHA384()

Synopsis

Returns the SHA384 message digest of the supplied argument as a string of hex characters. For string arguments, the trailing null character is not included in the digest. The availability of this function depends on the availability of the SHA384 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_SHA384 before running this function. See Library Option Constants for a list of all option constants.

Usage
SHA384(string | binary)
Example
$str = SHA384("hello"); # "59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f"

Table 3.248. Arguments and Return Values for SHA384()

Argument Type

Return Type

Description

String | Binary

String

Returns the SHA384 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.249. Exceptions thrown by SHA384()

err

desc

SHA384-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_SHA384 before calling this function.


3.9.24. SHA384_bin()

Synopsis

Returns the SHA384 message digest of the supplied argument as a string of hex characters. For string arguments, the trailing null character is not included in the digest. The availability of this function depends on the availability of the SHA384 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_SHA384 before running this function. See Library Option Constants for a list of all option constants.

Usage
SHA384_bin(string | binary)
Example
$bin = SHA384_bin("hello"); # <59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f>

Table 3.250. Arguments and Return Values for SHA384_bin()

Argument Type

Return Type

Description

String | Binary

String

Returns the SHA384 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.251. Exceptions thrown by SHA384_bin()

err

desc

SHA384-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_SHA384 before calling this function.


3.9.25. SHA512()

Synopsis

Returns the SHA512 message digest of the supplied argument as a string of hex characters. For string arguments, the trailing null character is not included in the digest. The availability of this function depends on the availability of the SHA512 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_SHA512 before running this function. See Library Option Constants for a list of all option constants.

Usage
SHA512(string | binary)
Example
$str = SHA512("hello"); # "9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043"

Table 3.252. Arguments and Return Values for SHA512()

Argument Type

Return Type

Description

String | Binary

String

Returns the SHA512 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.253. Exceptions thrown by SHA512()

err

desc

SHA512-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_SHA512 before calling this function.


3.9.26. SHA512_bin()

Synopsis

Returns the SHA512 message digest of the supplied argument as a string of hex characters. For string arguments, the trailing null character is not included in the digest. The availability of this function depends on the availability of the SHA512 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_SHA512 before running this function. See Library Option Constants for a list of all option constants.

Usage
SHA512_bin(string | binary)
Example
$bin = SHA512_bin("hello"); # <9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043>

Table 3.254. Arguments and Return Values for SHA512_bin()

Argument Type

Return Type

Description

String | Binary

String

Returns the SHA512 message digest of the supplied argument (for strings, the trailing null character is not included in the digest)


Table 3.255. Exceptions thrown by SHA512_bin()

err

desc

SHA512-DIGEST-ERROR

missing data parameter, invalid data parameter (expecing string or binary), error calculating digest

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_SHA512 before calling this function.