123456789101112131415161718192021222324252627282930313233 |
- /*
- * @Description: file content
- * @Version: 2.0
- * @Author: ljl
- * @Date: 2022-07-07 13:34:28
- * @LastEditors: ljl
- * @LastEditTime: 2022-07-07 14:33:12
- * @FilePath: \sui-shen-ban_alipay\src\utils\sm2.js
- */
- const sm2 = require('sm-crypto').sm2
- const cipherMode = 0 // 1 - C1C3C2,0 - C1C2C3,默认为1
- var publicKeyServer =
- "049FFE1205FDDDC59C52320F3DFE49805B2236865E74E96412C152E19591B7831D41FBDC094190F608B805BDE9E90EEFE5755327B8CA9D0EE961B1540F85A723F8";
- var privateKeyWeb = "008AD3D59BC6F6D8742EB27894A23FEF91296433BF9FCFF178713E37F60C526838";
- export default {
- encrypt(params) {
- if (typeof (params) == 'undefined') {
- params = null;
- } else {
- let encryptData = sm2.doEncrypt(params, publicKeyServer, cipherMode);
- return encryptData;
- }
- },
- decrypt(params) {
- if (typeof (params) == 'undefined') {
- params = null;
- } else {
- let decryptData = sm2.doDecrypt(params, privateKeyWeb, cipherMode);
- return decryptData;
- }
- }
- }
|