AES加密 - AESEncryptEx
函数简介
AES加密,支持多种加密模式和填充类型。
接口名称
AESEncryptEx
DLL调用
long AESEncryptEx(long instance, string source, string key, string iv, int mode, int paddingType);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| source | 字符串 | 源数据。 |
| key | 字符串 | 密钥。 |
| iv | 字符串 | 初始向量。 |
| mode | 整数型 | 加密模式:0-CBC;1-ECB;2-CFB;3-OFB;4-CTS。 |
| paddingType | 整数型 | 填充类型:0-PKCS7;1-Zeros;2-AnsiX923;3-ISO10126;4-NoPadding。 |
示例
C++
long instance = CreateCOLAPlugInterFace();
// AES-CBC模式加密,PKCS7填充
long ptr = AESEncryptEx(instance, "Hello OLA", "1234567890abcdef", "abcdef1234567890", 0, 0);
char* encrypted = GetStringFromPtr(ptr);
// 使用 AESDecryptEx 解密时需保持相同的 mode 和 paddingType
long ptr2 = AESDecryptEx(instance, encrypted, "1234567890abcdef", "abcdef1234567890", 0, 0);
FreeStringPtr(ptr);
FreeStringPtr(ptr2);
Python
# 待补充
返回值
成功返回加密后的数据的字符串指针;失败返回0。返回的字符串指针需要调用 FreeStringPtr 接口释放内存。
