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

> Descriptografa Base64 ciphertext com uma key decodificada de Base64 e um Base64 IV obrigatorio usando AES CBC ou 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
  ```

  ## Argumentos

  <ParamField path={"data"} type={"string"} required>
    Base64 ciphertext decodificado antes da descriptografia.
  </ParamField>

  <ParamField path={"key"} type={"string"} required>
    Key Base64 decodificada antes de ser passada para AES.
  </ParamField>

  <ParamField path={"iv"} type={"string"} required>
    Base64 IV decodificado antes do processamento de mode. Este argumento e obrigatorio, inclusive para ECB.
  </ParamField>

  <ParamField path={"mode"} type={"\"CBC\" | \"ECB\" | \"AES-CBC\" | \"AES-ECB\""}>
    AES mode. O prefixo AES- e removido quando presente. O padrao e AES-CBC.
  </ParamField>

  ## Retornos

  <ResponseField name={"plaintext"} type={"string"}>
    Bytes plaintext retornados como uma string Lua.
  </ResponseField>

  ## Exemplo

  Descriptografe o ciphertext retornado por crypt.encrypt usando o IV retornado.

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