Volt

crypt.generatekey

Generates a random encryption key.

Syntax

crypt.generatekey() -> string

Returns

TypeDescription
stringA Base64-encoded random key

Description

crypt.generatekey generates a cryptographically secure random key suitable for use with encryption functions.

Example

-- Generate a key
local key = crypt.generatekey()
print("Generated key:", key)

-- Use the key for encryption
local data = "Secret message"
local encrypted = crypt.encrypt(data, key)
local decrypted = crypt.decrypt(encrypted, key)

print("Original:", data)
print("Decrypted:", decrypted)

Notes

  • The key is suitable for AES encryption
  • Keys should be stored securely and not shared

On this page