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

> Вычисляет crypto library HMAC по байтам Lua string с raw Lua string key и возвращает Base64 digest.

<div className="real-function-page">
  ```lua theme={null}
  crypt.hmac(key: string, data: string, algorithm?: "sha256" | "sha1" | "sha224" | "sha384" | "sha512" | "md5"): string
  ```

  ## Аргументы

  <ParamField path={"key"} type={"string"} required>
    Байты raw Lua string, используемые как HMAC key. key не Base64-decode.
  </ParamField>

  <ParamField path={"data"} type={"string"} required>
    Байты Lua string, передаваемые в HMAC calculation.
  </ParamField>

  <ParamField path={"algorithm"} type={"\"sha256\" | \"sha1\" | \"sha224\" | \"sha384\" | \"sha512\" | \"md5\""}>
    Case-sensitive имя HMAC algorithm. Значение по умолчанию sha256.
  </ParamField>

  ## Возвраты

  <ResponseField name={"digest"} type={"string"}>
    Base64-encoded HMAC output без line breaks.
  </ResponseField>

  ## Пример

  Вычислите Base64 HMAC output из raw Lua string key и data.

  ```lua theme={null}
  local key = "shared secret"
  local data = "payload"
  local digest = crypt.hmac(key, data, "sha256")

  print(digest)
  ```
</div>
