前端引入jsrsasign进行RSA加密,登录Action增加RSA密码加密
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user