kit.program/kit/src/crypto.js
2024-03-07 15:50:13 +08:00

18 lines
442 B
JavaScript

const sm4 = require('sm-crypto').sm4
const sm3 = require('sm-crypto').sm3
module.exports.sm4en3 = function (key, data){
let sm3key = sm3(key)
sm3key = sm3key.substring(0, 32)
let encryptData = sm4.encrypt(data, sm3key)
return encryptData
}
module.exports.sm4de3 = function (key, data){
let sm3key = sm3(key)
sm3key = sm3key.substring(0, 32)
let decryptData = sm4.decrypt(data, sm3key)
return decryptData
}