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

> random byte generator で 32 個のランダム raw bytes を生成し、Base64-encoded として Lua string で返します。

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

  ## 戻り値

  <ResponseField name={"key"} type={"string"}>
    生成された 32 raw bytes の Base64 encoding。返される string は 32 文字ではありません。
  </ResponseField>

  ## 例

  Base64 key を生成し、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>
