Cryptography Functions
The Crypto category provides cryptographic operations that mirror the functionality of Crypto nodes.
Available Functions
Crypto.generateRandom(length, algorithm)- Generates random bytesCrypto.hash(value, algorithm, binaryPropertyName)- Computes a hash of the input valueCrypto.hmac(value, key, algorithm, binaryPropertyName)- Computes HMAC (Hash-based Message Authentication Code)Crypto.sign(value, privateKey, algorithm, binaryPropertyName)- Signs data with a private key
Examples
Generating Random Data
local random = Crypto.generateRandom(32, "SHA256")
Hashing
local hash = Crypto.hash("Hello World", "SHA256")
-- Returns hexadecimal hash string
HMAC
local hmac = Crypto.hmac("message", "secret-key", "SHA256")
-- Returns HMAC value
Signing
local signature = Crypto.sign("data", "private-key", "SHA256")
-- Returns signature
Parameters
value- The input value to hash/signkey- The secret key for HMACprivateKey- The private key for signingalgorithm- Hash algorithm (e.g., "SHA256", "SHA512", "MD5")binaryPropertyName- Optional property name for binary datalength- Length of random data to generate
Return Values
All functions return string values (hexadecimal representation for hashes and signatures).