import { sm4 } from "sm-crypto"; import { getEncryptionKey, fetchEncryptionKey, getEncryptionKeyBuffer, } from "./encryption"; // SM4加密函数 export const encryptBySM4 = (data) => { return sm4.encrypt(JSON.stringify(data), Buffer.from('2022lab02ora12to', 'utf-8')); }; // SM4解密函数 export const decryptBySM4 = (data) => { const key = fetchEncryptionKey(); // 获取当前密钥 return JSON.parse(sm4.decrypt(data, Buffer.from('2022lab02ora12to', 'utf-8'))); };