AES 加密

POST 加密解密 加密

AES 对称加密,将明文转为 Base64 密文。密钥长度支持 16、24、32 字节

POST https://api.tinyaii.cn/v1/encrypt/aes

请求参数

参数名类型必填说明示例
keystring必填密钥,长度必须为 16、24 或 32 字节,对应 AES-128/192/2561234567890123456
textstring必填待加密的明文文本Hello World

返回字段

字段类型说明
ciphertextstringBase64 编码的密文
ivstringBase64 编码的初始化向量(16字节)

返回示例

{
  "code": 200,
  "data": {
    "ciphertext": "3As6sXJua5EUeaeJbs1rbg==",
    "iv": "vmylQ0WOP62uDKEYpoQF5A=="
  },
  "message": "success"
}

调用示例

curl "https://api.tinyaii.cn/v1/encrypt/aes" \
  -X POST \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"key": "1234567890123456", "text": "Hello World"}'
const res = await fetch("https://api.tinyaii.cn/v1/encrypt/aes", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"key": "1234567890123456", "text": "Hello World"}),
});
console.log(await res.json());
import requests

resp = requests.post(
    "https://api.tinyaii.cn/v1/encrypt/aes",
    json={"key": "1234567890123456", "text": "Hello World"},
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    timeout=10,
)
print(resp.json())

把 YOUR_API_KEY 换成你的密钥即可直接运行。密钥只保存在你自己的设备上。