前端引入jsrsasign进行RSA加密,登录Action增加RSA密码加密

This commit is contained in:
2023-06-12 09:39:50 +08:00
parent 959e8976e0
commit 3e89c69a95
4 changed files with 37 additions and 21 deletions
+6 -1
View File
@@ -1,5 +1,5 @@
import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
import jsrsasign from 'jsrsasign'
// 密钥对生成 http://web.chacuo.net/netrsakeypair
const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALj0zjON+EVdBsnMcR4Uj+jOYgp5ZipftQZ1utW8KvVioz+RSaotF1JHt59q9SC/mZcWWpbpcEqQ3WyyyCC33msCAwEAAQ=='
@@ -20,3 +20,8 @@ export function decrypt(txt) {
encryptor.setPrivateKey(privateKey) // 设置私钥
return encryptor.decrypt(txt) // 对数据进行解密
}
export const encryptByPublicKey = (txt, publicKey) => {
const pubKey = jsrsasign.KEYUTIL.getKey(publicKey)
return jsrsasign.KJUR.crypto.Cipher.encrypt(txt, pubKey)
}