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

> Giai ma Base64 ciphertext bang key da decode tu Base64 va Base64 IV bat buoc voi AES CBC hoac ECB.

<div className="real-function-page">
  ```lua theme={null}
  crypt.decrypt(data: string, key: string, iv: string, mode?: "CBC" | "ECB" | "AES-CBC" | "AES-ECB"): string
  ```

  ## Đối số

  <ParamField path={"data"} type={"string"} required>
    Base64 ciphertext duoc decode truoc khi giai ma.
  </ParamField>

  <ParamField path={"key"} type={"string"} required>
    Base64 key duoc decode truoc khi truyen vao AES.
  </ParamField>

  <ParamField path={"iv"} type={"string"} required>
    Base64 IV duoc decode truoc khi xu ly mode. Doi so nay bat buoc, ke ca voi ECB.
  </ParamField>

  <ParamField path={"mode"} type={"\"CBC\" | \"ECB\" | \"AES-CBC\" | \"AES-ECB\""}>
    AES mode. Prefix AES- se bi xoa khi co. Mac dinh la AES-CBC.
  </ParamField>

  ## Giá trị trả về

  <ResponseField name={"plaintext"} type={"string"}>
    Cac byte plaintext duoc tra ve duoi dang Lua string.
  </ResponseField>

  ## Ví dụ

  Giai ma ciphertext do crypt.encrypt tra ve bang IV duoc tra ve.

  ```lua theme={null}
  local key = crypt.generatekey()
  local ciphertext, iv = crypt.encrypt("hello world", key)

  local plaintext = crypt.decrypt(ciphertext, key, iv)

  print(plaintext)
  ```
</div>
