# SM2接口
# 加密 decrypt
● 接口函数
zwexplorer.__gmUtil.sm2.decrypt
● 接口说明
sm2 加密
● Typescript 类型参考
type ReqBody ={
content?: string,//待加密、待解密、待签名或待验签的数据
privateKey?: string,//秘钥
publicKey?: string,//公钥
signValue?: string,//签名数据
key?: string,// sm3,sm4加密的key
options?: any,//参数
}
type ResBody = {
resultCode: number
resultMessage?: string
data?: any
}
zwexplorer.__gmUtil.sm2.decrypt(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 状态码,-1 时失败 |
res.resultMessage | String | 是 | 提示消息 |
res.data | Buffer | 是 | 返回 Buffer 字节数组 |
● 示例
const data = { content: "qqq", privateKey: "xxx" };
zwexplorer.__gmUtil.sm2.decrypt(data, (res) => {});
# 解密 encrypt
● 接口函数
zwexplorer.__gmUtil.sm2.encrypt
● 接口说明
sm2 解密
● Typescript 类型参考
type ReqBody ={
content?: string,//待加密、待解密、待签名或待验签的数据
privateKey?: string,//秘钥
publicKey?: string,//公钥
signValue?: string,//签名数据
key?: string,// sm3,sm4加密的key
options?: any,//参数
}
type ResBody = {
resultCode: number
resultMessage?: string
data?: any
}
zwexplorer.__gmUtil.sm2.encrypt(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 状态码,-1 时失败 |
res.resultMessage | String | 是 | 提示消息 |
res.data | Buffer | 是 | 返回 Buffer 字节数组 |
● 示例
const data = { content: "qqq", privateKey: "xxx" };
zwexplorer.__gmUtil.sm2.encrypt(data, (res) => {});
# 秘钥生成 generateKeyPair
● 接口函数
zwexplorer.__gmUtil.sm2.generateKeyPair
● 接口说明
sm2 秘钥生成
● Typescript 类型参考
type ReqBody ={
content?: string,//待加密、待解密、待签名或待验签的数据
privateKey?: string,//秘钥
publicKey?: string,//公钥
signValue?: string,//签名数据
key?: string,// sm3,sm4加密的key
options?: any,//参数
}
type ResBody = {
resultCode: number
resultMessage?: string
data?: any
}
zwexplorer.__gmUtil.sm2.generateKeyPair(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 状态码,-1 时失败 |
res.resultMessage | String | 是 | 提示消息 |
res.data | Buffer | 是 | 返回 Buffer 字节数组 |
● 示例
const data = { content: "qqq", privateKey: "xxx" };
zwexplorer.__gmUtil.sm2.generateKeyPair(data, (res) => {});
# 签名 sign
● 接口函数
zwexplorer.__gmUtil.sm2.sign
● 接口说明
sm2 签名
● Typescript 类型参考
type ReqBody ={
content?: string,//待加密、待解密、待签名或待验签的数据
privateKey?: string,//秘钥
publicKey?: string,//公钥
signValue?: string,//签名数据
key?: string,// sm3,sm4加密的key
options?: any,//参数
}
type ResBody = {
resultCode: number
resultMessage?: string
data?: any
}
zwexplorer.__gmUtil.sm2.sign(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 状态码,-1 时失败 |
res.resultMessage | String | 是 | 提示消息 |
res.data | Buffer | 是 | 返回 Buffer 字节数组 |
● 示例
const data = { content: "qqq", privateKey: "xxx" };
zwexplorer.__gmUtil.sm2.sign(data, (res) => {});
# 签名验证 verify
● 接口函数
zwexplorer.__gmUtil.sm2.verify
● 接口说明
sm2 签名验证
● Typescript 类型参考
type ReqBody ={
content?: string,//待加密、待解密、待签名或待验签的数据
privateKey?: string,//秘钥
publicKey?: string,//公钥
signValue?: string,//签名数据
key?: string,// sm3,sm4加密的key
options?: any,//参数
}
type ResBody = {
resultCode: number
resultMessage?: string
data?: any
}
zwexplorer.__gmUtil.sm2.verify(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 状态码,-1 时失败 |
res.resultMessage | String | 是 | 提示消息 |
res.data | Buffer | 是 | 返回 Buffer 字节数组 |
● 示例
const data = { content: "qqq", privateKey: "xxx" };
zwexplorer.__gmUtil.sm2.verify(data, (res) => {});
# SM3 接口
# 杂凑 digest
● 接口函数
zwexplorer.__gmUtil.sm3.digest
● 接口说明
sm3 杂凑
● Typescript 类型参考
type ReqBody ={
content?: string,//待加密、待解密、待签名或待验签的数据
privateKey?: string,//秘钥
publicKey?: string,//公钥
signValue?: string,//签名数据
key?: string,// sm3,sm4加密的key
options?: any,//参数
}
type ResBody = {
resultCode: number
resultMessage?: string
data?: any
}
zwexplorer.__gmUtil.sm3.digest(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 状态码,-1 时失败 |
res.resultMessage | String | 是 | 提示消息 |
res.data | Buffer | 是 | 返回 Buffer 字节数组 |
● 示例
const data = { content: "qqq", privateKey: "xxx" };
zwexplorer.__gmUtil.sm3.digest(data, (res) => {});
# SM4 接口
# 加密 encrypt
● 接口函数
zwexplorer.__gmUtil.sm4.encrypt
● 接口说明
sm4加密
● Typescript 类型参考
type ReqBody ={
content?: string,//待加密、待解密、待签名或待验签的数据
privateKey?: string,//秘钥
publicKey?: string,//公钥
signValue?: string,//签名数据
key?: string,// sm3,sm4加密的key
options?: any,//参数
}
type ResBody = {
resultCode: number
resultMessage?: string
data?: any
}
zwexplorer.__gmUtil.sm4.encrypt(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 状态码,-1 时失败 |
res.resultMessage | String | 是 | 提示消息 |
res.data | Buffer | 是 | 返回 Buffer 字节数组 |
● 示例
const data = { content: "qqq", privateKey: "xxx" };
zwexplorer.__gmUtil.sm4.encrypt(data, (res) => {});
# 解密 decrypt
● 接口函数
zwexplorer.__gmUtil.sm4.decrypt
● 接口说明
sm4解密
● Typescript 类型参考
type ReqBody ={
content?: string,//待加密、待解密、待签名或待验签的数据
privateKey?: string,//秘钥
publicKey?: string,//公钥
signValue?: string,//签名数据
key?: string,// sm3,sm4加密的key
options?: any,//参数
}
type ResBody = {
resultCode: number
resultMessage?: string
data?: any
}
zwexplorer.__gmUtil.sm4.decrypt(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 状态码,-1 时失败 |
res.resultMessage | String | 是 | 提示消息 |
res.data | Buffer | 是 | 返回 Buffer 字节数组 |
● 示例
const data = { content: "qqq", privateKey: "xxx" };
zwexplorer.__gmUtil.sm4.decrypt(data, (res) => {});