vue 加国密 sm2

国密

npm install --save sm-crypto

公钥

// 方法一
import {sm2} from 'sm-crypto'
 
const public_key = '04' + '公钥'
let passwordd= sm2.doEncrypt('登陆密码', public_key, 1)
 
 
// 方法二
const sm2 = require('sm-crypto').sm2
const public_key = '04' + '公钥'
const cipherMode = 1  // 1 - C1C3C2,0 - C1C2C3,默认为1
let pwd= sm2.doEncrypt('登陆密码', public_key, cipherMode) // sm2加密

 

posted @ 2024-04-25 09:35  ThisCall  阅读(324)  评论(0编辑  收藏  举报