2021-03-08 18:19:57 +08:00
|
|
|
import JSEncrypt from 'jsencrypt/bin/jsencrypt'
|
|
|
|
|
|
|
|
// 密钥对生成 http://web.chacuo.net/netrsakeypair
|
|
|
|
|
2021-11-01 17:57:59 +08:00
|
|
|
/* const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD\n' +
|
2021-03-08 18:19:57 +08:00
|
|
|
'2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ=='
|
2021-11-01 17:57:59 +08:00
|
|
|
*/
|
2021-03-08 18:19:57 +08:00
|
|
|
|
|
|
|
// 加密
|
|
|
|
export function encrypt(txt) {
|
2021-11-01 17:57:59 +08:00
|
|
|
const publicKey = localStorage.getItem('publicKey')
|
2021-03-08 18:19:57 +08:00
|
|
|
const encryptor = new JSEncrypt()
|
|
|
|
encryptor.setPublicKey(publicKey) // 设置公钥
|
|
|
|
return encryptor.encrypt(txt) // 对需要加密的数据进行加密
|
|
|
|
}
|
|
|
|
|
|
|
|
// 解密
|
2021-11-01 17:57:59 +08:00
|
|
|
/* export function decrypt(txt) {
|
2021-03-08 18:19:57 +08:00
|
|
|
const encryptor = new JSEncrypt()
|
|
|
|
encryptor.setPrivateKey(privateKey)
|
|
|
|
return encryptor.decrypt(txt)
|
2021-11-01 17:57:59 +08:00
|
|
|
} */
|
2021-10-25 15:36:51 +08:00
|
|
|
|