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

> Tao 32 raw bytes ngau nhien bang random byte generator va tra ve chung Base64-encoded duoi dang Lua string.

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

  ## Giá trị trả về

  <ResponseField name={"key"} type={"string"}>
    Base64 encoding cua 32 raw bytes da tao. String duoc tra ve khong dai 32 ky tu.
  </ResponseField>

  ## Ví dụ

  Tao Base64 key va decode no de kiem tra so luong 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>
