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

# Cryptography

> 编码、散列、加密和压缩。

<div className="real-category-page">
  编码、散列、加密和压缩。

  ## 可用函数

  <CardGroup cols={2}>
    <Card title="base64_decode" href="./base64-decode">
      使用 Base64 decoder 解码 Base64 输入，并将解码后的字节作为 Lua string 返回。
    </Card>

    <Card title="base64_encode" href="./base64-encode">
      使用 Base64 encoder 编码 Lua string 的字节，使用 = padding 且不插入换行。
    </Card>

    <Card title="crypt.decrypt" href="./crypt-decrypt">
      使用从 Base64 解码的 key 和必需的 Base64 IV，通过 AES CBC 或 ECB 解密 Base64 ciphertext。
    </Card>

    <Card title="crypt.encrypt" href="./crypt-encrypt">
      使用从 Base64 解码的 key，通过 AES CBC、ECB 或 CTR 加密 Lua string 字节，然后返回 Base64 ciphertext 和 IV 结果。
    </Card>

    <Card title="crypt.generatebytes" href="./crypt-generatebytes">
      使用 random byte generator 生成随机字节，并以 Base64-encoded Lua string 返回。
    </Card>

    <Card title="crypt.generatekey" href="./crypt-generatekey">
      使用 random byte generator 生成 32 个随机 raw bytes，并以 Base64-encoded Lua string 返回。
    </Card>

    <Card title="crypt.hash" href="./crypt-hash">
      使用受支持的 crypto library hash 算法对 Lua string 字节进行 hash，并返回 lowercase hexadecimal digest。
    </Card>

    <Card title="crypt.hmac" href="./crypt-hmac">
      使用 raw Lua string key 对 Lua string 字节计算 crypto library HMAC，并返回 Base64 digest。
    </Card>

    <Card title="crypt.random" href="./crypt-random">
      使用 random byte generator 生成 raw random bytes，并作为 Lua string 返回。
    </Card>

    <Card title="lz4compress" href="./lz4compress">
      使用 LZ4 block compression 压缩 Lua string 字节，并将 raw compressed bytes 作为 Lua string 返回。
    </Card>

    <Card title="lz4decompress" href="./lz4decompress">
      使用 LZ4 block decompression 解压 raw LZ4 block bytes，并以 Lua 字符串返回 raw decompressed bytes。
    </Card>
  </CardGroup>
</div>
