-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Description
declare module 'miniprogram-sm-crypto' {
export const sm2: {
doEncrypt: (message: string, publicKey: string, cipherMode: number) => string;
doDecrypt: (message: string, privateKey: string, cipherMode: number) => string;
/**
* 验签
*/
doVerifySignature: (
msg: string,
signHex: string,
publicKey: string,
options?: { der?: boolean; hash?: boolean; userId?: string }
) => boolean;
/**
* 获取椭圆曲线点
*/
getPoint: () => any;
/**
* 计算公钥
*/
getPublicKeyFromPrivateKey: (privateKey: string) => string;
/**
* 签名
*/
doSignature: (
msg: string,
privateKey: string,
options?: { pointPool?: any; der?: boolean; hash?: boolean; publicKey?: string; userId?: string }
) => string;
/**
* 验证公钥是否为椭圆曲线上的点
*/
verifyPublicKey: (publicKey: string) => boolean;
/**
* 生成密钥对:publicKey = privateKey * G
*/
generateKeyPairHex: (a?: any, b?: any, c?: any) => { publicKey: string; privateKey: string };
/**
* 生成压缩公钥
*/
compressPublicKeyHex: (s: string) => string;
/**
* 验证公钥是否等价,等价返回true
*/
comparePublicKeyHex: (publicKey1: string, publicKey2: string) => boolean;
};
/**
* hmac 实现
* @param input 输入字符串
* @param aesKey 可选的AES密钥
* @returns 哈希值
*/
export function sm3(input: string, aesKey?: string): string;
/**
* sm4 实现
*/
export const sm4: {
/**
* 加密
* @param message 加密内容
* @param key 密钥
* @param options 可选参数
* @returns 加密后的字符串
*/
encrypt: (
message: string,
key: string,
options?: { padding?: 'pkcs#7'; mode?: string; iv?: any[]; output?: 'string' }
) => string;
/**
* 解密
* @param message 加密内容
* @param key 密钥
* @param options 可选参数
* @returns 解密后的字符串
*/
decrypt: (
message: string,
key: string,
options?: { padding?: 'pkcs#7'; mode?: string; iv?: any[]; output?: 'string' }
) => string;
};
}
Metadata
Metadata
Assignees
Labels
No labels