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