1.下载
npm install sm-crypto
2.sm2.js
import {sm2} from 'sm-crypto';
const publicKey = '找后端要';
const privateKey = '找后端要';
export const setPassword = (password)=>{
return '04' + sm2.doEncrypt(password,publicKey,1);
};
export const getPassword = (password)=>{
return sm2.doDecrypt(password.slice(2),privateKey,1);
};
加密调用setPassword, 解密用getPassword