UNPKG

@sparta-utils/cache-util

Version:

统一的浏览器缓存工具类,支持 localStorage、sessionStorage、memory、cookie、indexedDB,内置 SM2 加密与过期机制。A unified browser caching utility supporting localStorage, sessionStorage, memory, cookie, indexedDB with SM2 encryption and expiration.

18 lines (17 loc) 599 B
declare class SM2Util { private privateKey; private publicKey; constructor(); /** 初始化密钥对,优先从 localStorage 读取,否则生成新的并保存 */ private _initKeys; /** 加密字符串,输出 hex 编码 */ encrypt(data: string): string; /** 解密 hex 编码字符串 */ decrypt(encrypted: string): string; /** 清除本地密钥(调试或切换用户时可用) */ resetKeys(): void; /** 获取公钥(如果需要公开传输用) */ getPublicKey(): string; } declare const _default: SM2Util; export default _default;