DIGEST()

Top  Previous  Next

 

The DIGEST() function returns the message digest string for a supplied string or file.

 

 

Format

 

DIGEST(string, is.file, mode)

 

where

 

stringis either the string to be encoded or the pathname of a file containing data to be encoded.

 

is.fileis a Boolean value indicating whether string is the actual data string or a pathname.

 

modeevaluates to the name of the digest algorithm to be used. Supported algorithms are MD4, MD5, SHA1, SHA256, SHA384 and SHA512.

 

 

If successful, the DIGEST() returns the result of applying the specified digest algorithm to the supplied data and the STATUS() function will return zero. All error conditions return a null string and the STATUS() function can be used to determine the cause.

 

 

Example

 

DISPLAY 'Password: ' :

INPUT PASSWORD

IF DIGEST(PASSWORD, @FALSE, 'SHA256') # ENCRYPTED.PASSWORD THEN

  DISPLAY 'Access denied'

  RETURN

END

 

The above example compares a password entered by the user with a stored message digest value for the correct password. Because message digests are not reversible, there is no way to determine the actual password from the stored value.

 

 

See also:

MD5()