UNPKG

@ivujs/i-utils

Version:

前端模块化 JavaScript 工具库

28 lines (24 loc) 593 B
'use strict'; var sm3 = require('./sm3.cjs'); /** * sm3 加密 * @param {string} str 字符串 * @returns {string} 返回加密后的字符串 */ function sm3Encrypt(str) { return sm3.encrypt(str); } /** * sm3_hmac 加密 * @param {string} str 字符串 * @param {string} key 配置 * @returns {string} 返回加密后的字符串 */ function sm3EncryptHmac(str, key) { if (!str || !key) { throw new TypeError("sm3EncryptHmac: missing str or key"); } return sm3.encrypt(str, key); } exports.sm3Encrypt = sm3Encrypt; exports.sm3EncryptHmac = sm3EncryptHmac;