UNPKG

yggjs-gm

Version:

国密算法 TypeScript 库 - 支持 SM2/SM3/SM4 算法的现代化实现

38 lines (34 loc) 866 B
'use strict'; var smCrypto = require('sm-crypto'); /* yggjs-gm - 国密算法 TypeScript 库 */ var getKey = () => { const keypair = smCrypto.sm2.generateKeyPairHex(); const privateKey = keypair.privateKey; const publicKey = keypair.publicKey; return { privateKey, publicKey }; }; var sm2Encrypt = (publicKey, text) => { return smCrypto.sm2.doEncrypt(text, publicKey, 0); }; var sm2Decrypt = (privateKey, encryptedText) => { return smCrypto.sm2.doDecrypt(encryptedText, privateKey, 0); }; var src_default = { getKey, sm2Encrypt, sm2Decrypt }; /** * 国密算法 TypeScript 库主入口 * * @description 提供 SM2/SM3/SM4 国密算法的现代化 TypeScript 实现 * @version 0.1.0 * @author YggJS Team * @license Apache-2.0 */ module.exports = src_default; //# sourceMappingURL=index.cjs.map //# sourceMappingURL=index.cjs.map