> ## 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 с key, декодированным из Base64, и обязательным 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>
    Base64 key, декодируемый перед передачей в AES.
  </ParamField>

  <ParamField path={"iv"} type={"string"} required>
    Base64 IV, декодируемый перед обработкой mode. Этот аргумент обязателен, включая ECB.
  </ParamField>

  <ParamField path={"mode"} type={"\"CBC\" | \"ECB\" | \"AES-CBC\" | \"AES-ECB\""}>
    AES mode. Prefix AES- удаляется, если он присутствует. Значение по умолчанию AES-CBC.
  </ParamField>

  ## Возвраты

  <ResponseField name={"plaintext"} type={"string"}>
    Байты plaintext, возвращаемые как Lua string.
  </ResponseField>

  ## Пример

  Расшифруйте ciphertext, возвращенный crypt.encrypt, используя возвращенный 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>
