crypt. generatekey Synchronous
Generate a fresh AES key in the exact format crypt.encrypt expects. Keep this value if you need to decrypt the resulting ciphertext after the script ends.
Luau
crypt.generatekey() -> stringParameters
This function takes no arguments.
Returns
stringA Base64-encoded 32-byte key string.
Usage notes
Calling it again creates a different key; it does not retrieve an earlier one.
Example
Luau
local key = crypt.generatekey()
local ciphertext, iv = crypt.encrypt("saved value", key, nil, "GCM")
print(#key, #ciphertext, #iv)
assert(crypt.decrypt(ciphertext, key, iv, "GCM") == "saved value")