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.

Prototype

string DSS(data)

Example
$str = DSS("hello"); # returns "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"

Table 3.233. Arguments and Return Values for DSS()

Argument Type

Return Type

Description

data

string

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


Table 3.234. 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.

Prototype

binary DSS_bin(data)

Example
$bin = DSS_bin("hello"); # returns <aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d>

Table 3.235. Arguments and Return Values for DSS_bin()

Argument Type

Return Type

Description

data

binary

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


Table 3.236. 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.

Prototype

string DSS1(data)

Example
$str = DSS1("hello"); # return "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"

Table 3.237. Arguments and Return Values for DSS1()

Argument Type

Return Type

Description

data

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.238. 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.

Prototype

binary DSS1_bin(data)

Example
$bin = DSS1_bin("hello"); # returns <aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d>

Table 3.239. Arguments and Return Values for DSS1_bin()

Argument Type

Return Type

Description

data

binary

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


Table 3.240. 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.

Prototype

string MD2(data)

Example
$str = MD2("hello"); # returns "a9046c73e00331af68917d3804f70655"

Table 3.241. Arguments and Return Values for MD2()

Argument Type

Return Type

Description

data

string

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


Table 3.242. 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.

Prototype

binary MD2_bin(data)

Example
$bin = MD2_bin("hello"); # returns <a9046c73e00331af68917d3804f70655>

Table 3.243. Arguments and Return Values for MD2_bin()

Argument Type

Return Type

Description

data

binary

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


Table 3.244. 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.

Prototype

string MD4(data)

Example
$str = MD4("hello"); # returns "866437cb7a794bce2b727acc0362ee27"

Table 3.245. Arguments and Return Values for MD4()

Argument Type

Return Type

Description

data

string

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


Table 3.246. 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.

Prototype

binary MD4_bin(data)

Example
$str = MD4_bin("hello"); # returns "866437cb7a794bce2b727acc0362ee27"

Table 3.247. Arguments and Return Values for MD4_bin()

Argument Type

Return Type

Description

data

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.248. 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.

Prototype

string MD5(data)

Example
$str = MD5("hello"); # returns "5d41402abc4b2a76b9719d911017c592"

Table 3.249. Arguments and Return Values for MD5()

Argument Type

Return Type

Description

data

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.250. 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.

Prototype

binary MD5_bin(data)

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

Table 3.251. Arguments and Return Values for MD5_bin()

Argument Type

Return Type

Description

data

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.252. 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).

Prototype

string MDC2(data)

Example
$str = MDC2("hello");
Platform Availability

HAVE_MDC2

Table 3.253. Arguments and Return Values for MDC2()

Argument Type

Return Type

Description

data

string

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


Table 3.254. 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.

Prototype

binary MDC2_bin(data)

Example
$bin = MDC2_bin("hello");
Platform Availability

HAVE_MDC2

Table 3.255. Arguments and Return Values for MDC2_bin()

Argument Type

Return Type

Description

data

binary

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


Table 3.256. 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.

Prototype

string RIPEMD160(data)

Example
$str = RIPEMD160("hello"); # returns "108f07b8382412612c048d07d13f814118445acd"

Table 3.257. Arguments and Return Values for RIPEMD160()

Argument Type

Return Type

Description

data

string

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


Table 3.258. 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.

Prototype

binary RIPEMD160_bin(data)

Example
$str = RIPEMD160_bin("hello"); # returns "108f07b8382412612c048d07d13f814118445acd"

Table 3.259. Arguments and Return Values for RIPEMD160_bin()

Argument Type

Return Type

Description

data

binary

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


Table 3.260. 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.

Prototype

string SHA(data)

Example
$str = SHA("hello"); returns "ac62a630ca850b4ea07eda664eaecf9480843152"

Table 3.261. Arguments and Return Values for SHA()

Argument Type

Return Type

Description

data

string

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


Table 3.262. 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)

Prototype

binary SHA_bin(data)

Example
$bin = SHA_bin("hello"); returns <ac62a630ca850b4ea07eda664eaecf9480843152>

Table 3.263. Arguments and Return Values for SHA_bin()

Argument Type

Return Type

Description

data

binary

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


Table 3.264. 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.

Prototype

string SHA1(data)

Example
$str = SHA1("hello"); # "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"

Table 3.265. Arguments and Return Values for SHA1()

Argument Type

Return Type

Description

data

string

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


Table 3.266. 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.

Prototype

binary SHA1_bin(data)

Example
$bin = SHA1_bin("hello"); # <aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d>

Table 3.267. Arguments and Return Values for SHA1_bin()

Argument Type

Return Type

Description

data

string

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


Table 3.268. 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.

Prototype

string SHA224(data)

Example
$str = SHA224("hello"); # "ea09ae9cc6768c50fcee903ed054556e5bfc8347907f12598aa24193"
Platform Availability

HAVE_SHA224

Table 3.269. Arguments and Return Values for SHA224()

Argument Type

Return Type

Description

data

string

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


Table 3.270. 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.

Prototype

binary SHA224_bin(data)

Example
$bin = SHA224_bin("hello");
# <ea09ae9cc6768c50fcee903ed054556e5bfc8347907f12598aa24193>
Platform Availability

HAVE_SHA224

Table 3.271. Arguments and Return Values for SHA224_bin()

Argument Type

Return Type

Description

data

string

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


Table 3.272. 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.

Prototype

binary SHA256_bin(data)

Example
$str = SHA256("hello");
# "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
Platform Availability

HAVE_SHA256

Table 3.273. Arguments and Return Values for SHA256()

Argument Type

Return Type

Description

data

string

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


Table 3.274. 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.

Prototype

binary SHA256_bin(data)

Example
$bin = SHA256_bin("hello");
# <2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824>
Platform Availability

HAVE_SHA256

Table 3.275. Arguments and Return Values for SHA256_bin()

Argument Type

Return Type

Description

data

string

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


Table 3.276. 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.

Prototype

binary SHA384_bin(data)

Example
$str = SHA384("hello");
# "59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f"
Platform Availability

HAVE_SHA384

Table 3.277. Arguments and Return Values for SHA384()

Argument Type

Return Type

Description

data

string

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


Table 3.278. 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.

Prototype

binary SHA384_bin(data)

Example
$bin = SHA384_bin("hello");
# <59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f>
Platform Availability

HAVE_SHA384

Table 3.279. Arguments and Return Values for SHA384_bin()

Argument Type

Return Type

Description

data

string

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


Table 3.280. 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.

Prototype

binary SHA512_bin(data)

Example
$str = SHA512("hello");
# "9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043"
Platform Availability

HAVE_SHA512

Table 3.281. Arguments and Return Values for SHA512()

Argument Type

Return Type

Description

data

string

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


Table 3.282. 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.

Prototype

binary SHA512_bin(data)

Example
$bin = SHA512_bin("hello");
# <9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043>
Platform Availability

HAVE_SHA512

Table 3.283. Arguments and Return Values for SHA512_bin()

Argument Type

Return Type

Description

data

string

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


Table 3.284. 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.