UNPKG

@sparta-utils/crypto-util

Version:

一个支持多种加密算法的加密工具库,涵盖 AES、RSA、SM2、SM3、SM4、SHA、HMAC、MD5、Base64、JWT 等,适用于日常加解密、签名验签、摘要、Token 管理等场景。

22 lines (21 loc) 536 B
import { Sm2KeyPair } from '../types'; /** * 生成 SM2 公私钥对 */ export declare function generateKeyPair(): Sm2KeyPair; /** * SM2 加密 */ export declare function encrypt(text: string, publicKey: string): string; /** * SM2 解密 */ export declare function decrypt(encrypted: string, privateKey: string): string; /** * SM2 签名 */ export declare function sign(data: string, privateKey: string): string; /** * SM2 验签 */ export declare function verify(data: string, signature: string, publicKey: string): boolean;