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

> Base64 ciphertext を、Base64 からデコードされた key と必須の Base64 IV で AES CBC または 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
  ```

  ## 引数

  <ParamField path={"data"} type={"string"} required>
    復号前にデコードされる Base64 ciphertext。
  </ParamField>

  <ParamField path={"key"} type={"string"} required>
    AES に渡される前にデコードされる Base64 key。
  </ParamField>

  <ParamField path={"iv"} type={"string"} required>
    mode 処理前にデコードされる Base64 IV。この引数は ECB でも必須です。
  </ParamField>

  <ParamField path={"mode"} type={"\"CBC\" | \"ECB\" | \"AES-CBC\" | \"AES-ECB\""}>
    AES mode。存在する場合は AES- prefix が削除されます。デフォルトは AES-CBC です。
  </ParamField>

  ## 戻り値

  <ResponseField name={"plaintext"} type={"string"}>
    Lua string として返される plaintext バイト。
  </ResponseField>

  ## 例

  crypt.encrypt が返した ciphertext を、返された IV で復号します。

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