主题
使用RSA公钥验证签名 - VerifySignWithRsa
函数简介
使用RSA公钥验证数据的签名。
接口名称
VerifySignWithRsaDLL调用
c
int VerifySignWithRsa(long instance, string message, string signature, int shaType, int paddingType, string publicCer);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| message | 字符串 | 要验证的明文。 |
| signature | 字符串 | 签名数据。 |
| shaType | 整数型 | 哈希类型:0-MD5;1-SHA1;2-SHA256;3-SHA384;4-SHA512;5-SHA3-256;6-SHA3-384;7-SHA3-512。 |
| paddingType | 整数型 | 填充类型:0-Pkcs1;1-Pss。 |
| publicCer | 字符串 | RSA公钥。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
std::string signature = ola.SignWithRsa("hello ola", privateKey, 2, 0);
int ok = ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);csharp
using OLAPlug;
var ola = new OLAPlugServer();
string signature = ola.SignWithRsa("hello ola", privateKey, 2, 0);
int ok = ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
signature = ola.SignWithRsa("hello ola", private_key, 2, 0)
ok = ola.VerifySignWithRsa("hello ola", signature, 2, 0, public_key)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);cpp
var ola = com("OlaPlug.OlaSoft")
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);text
.局部变量 ola, OLAPlug
ola.创建 ()
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);aardio
import OLAPlugServer;
var ola = OLAPlugServer();
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
VerifySignWithRsa(instance, "hello ola", signature, 2, 0, publicKey);csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int VerifySignWithRsa(long ola, string message, string signature, int shaType, int paddingType, string publicCer);
long instance = CreateCOLAPlugInterFace();
int ok = VerifySignWithRsa(instance, "hello ola", signature, 2, 0, publicKey);python
long instance = CreateCOLAPlugInterFace();
VerifySignWithRsa(instance, "hello ola", signature, 2, 0, publicKey);返回值
| 返回值 | 说明 |
|---|---|
1 | 成功。 |
0 | 失败。 |
注意事项
| 项目 | 说明 |
|---|---|
| 验证时使用的哈希类型和填充类型必须与签名时一致 | 验证时使用的哈希类型和填充类型必须与签名时一致。 |
