crypto.digest()

Type Function
Library crypto.*
Return value String
Revision Release 2024.3703
Keywords crypto, hash, digest

Overview

Generates the message digest (the hash) of the input string.

Syntax

crypto.digest( algorithm, data [, raw] )
algorithm (required)

Constant. A constant specifying the hashing algorithm (see Constants for crypto.*).

data (required)

String. The input string.

raw (optional)

Boolean. Indicates whether the output should be a direct binary equivalent of the message digest. If false (default), the result is formatted as a hexadecimal string.

Example

local crypto = require( "crypto" )
local hash = crypto.digest( crypto.md4, "test" )
print( hash )   --> db346d691d7acc4dc2625db19f9e3f52