> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# crypt.generatekey

> Generates 32 random raw bytes with random byte generator and returns them Base64-encoded as a Lua string.

<div className="real-function-page">
  ```lua theme={null}
  crypt.generatekey(): string
  ```

  ## Returns

  <ResponseField name={"key"} type={"string"}>
    Base64 encoding of the generated 32 raw bytes. The returned string is not 32 characters long.
  </ResponseField>

  ## Example

  Generate a Base64 key and decode it to inspect the raw byte count.

  ```lua theme={null}
  local key = crypt.generatekey()
  local raw = base64_decode(key)

  local ciphertext, iv = crypt.encrypt("hello world", key)

  print(key)
  print(#raw)
  print(ciphertext, iv)
  ```
</div>
