> ## 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

> Genere 32 raw bytes aleatoires avec random byte generator et les renvoie Base64-encoded sous forme de chaine Lua.

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

  ## Retours

  <ResponseField name={"key"} type={"string"}>
    Base64 encoding des 32 raw bytes generes. La chaine renvoyee ne fait pas 32 caracteres.
  </ResponseField>

  ## Exemple

  Genere une Base64 key et decode-la pour inspecter le nombre de raw bytes.

  ```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>
