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

> Dechiffre un Base64 ciphertext avec une key decodee depuis Base64 et un Base64 IV requis en utilisant 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
  ```

  ## Arguments

  <ParamField path={"data"} type={"string"} required>
    Base64 ciphertext decode avant le dechiffrement.
  </ParamField>

  <ParamField path={"key"} type={"string"} required>
    Key Base64 decodee avant d etre transmise a AES.
  </ParamField>

  <ParamField path={"iv"} type={"string"} required>
    Base64 IV decode avant le traitement de mode. Cet argument est requis, meme avec ECB.
  </ParamField>

  <ParamField path={"mode"} type={"\"CBC\" | \"ECB\" | \"AES-CBC\" | \"AES-ECB\""}>
    AES mode. Le prefixe AES- est supprime quand il est present. La valeur par defaut est AES-CBC.
  </ParamField>

  ## Retours

  <ResponseField name={"plaintext"} type={"string"}>
    Octets plaintext renvoyes sous forme de chaine Lua.
  </ResponseField>

  ## Exemple

  Dechiffre le ciphertext renvoye par crypt.encrypt avec le IV renvoye.

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