UNPKG

@sparta-utils/crypto-util

Version:

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

22 lines (21 loc) 621 B
import type { RsaKeyPair } from '../types'; /** * 生成 RSA 公钥和私钥 */ export declare function generateKeyPair(): RsaKeyPair; /** * 使用 RSA 公钥加密 */ export declare function encrypt(data: string, publicKey: string): string; /** * 使用 RSA 私钥解密 */ export declare function decrypt(encryptedData: string, privateKey: string): string; /** * 使用 RSA 私钥对数据进行签名 */ export declare function sign(data: string, privateKey: string): string; /** * 使用 RSA 公钥验证签名 */ export declare function verify(data: string, signature: string, publicKey: string): boolean;