AES 加密
AES 对称加密,将明文转为 Base64 密文。密钥长度支持 16、24、32 字节
POST
https://api.tinyaii.cn/v1/encrypt/aes
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| key | string | 必填 | 密钥,长度必须为 16、24 或 32 字节,对应 AES-128/192/256 | 1234567890123456 |
| text | string | 必填 | 待加密的明文文本 | Hello World |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| ciphertext | string | Base64 编码的密文 |
| iv | string | Base64 编码的初始化向量(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 换成你的密钥即可直接运行。密钥只保存在你自己的设备上。