生成RSA密钥 - GenerateRSAKey
函数简介
生成RSA密钥对,包括公钥和私钥,支持多种格式和密钥大小。
接口名称
GenerateRSAKey
DLL调用
int GenerateRSAKey(long instance, string publicKeyPath, string privateKeyPath, int type, int keySize);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| publicKeyPath | 字符串 | 公钥保存路径。 |
| privateKeyPath | 字符串 | 私钥保存路径。 |
| type | 整数型 | 类型:0-生成pem格式秘钥;1-生成xml格式秘钥;2-生成PKCS1格式秘钥。 |
| keySize | 整数型 | 密钥大小:512-512位;1024-1024位;2048-2048位;4096-4096位。 |
示例
C++
long instance = CreateCOLAPlugInterFace();
// 生成2048位PEM格式RSA密钥对
int ret = GenerateRSAKey(instance, "C:\\keys\\public.pem", "C:\\keys\\private.pem", 0, 2048);
// ret == 0 表示成功,密钥已保存到指定路径
Python
# 待补充
返回值
成功返回0;失败返回其他值。
注意事项
- 生成的密钥文件将保存到指定的路径。
- 建议使用2048位或更高位数的密钥以保证安全性。
