// RSA
|
import JSEncrypt from 'jsencrypt'
|
/******************************************************************************/
|
// 公钥
|
|
// const publicKey = uni.getStorageSync('aes_public_key')
|
const publicKey =
|
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOgrUW4jM5Y" +
|
"2irUCpvpyBn41aTRfGHNQuBHIByK9fbc" +
|
"lNXXt7/QuQj3NQCfwknBBCHcM7A38eC249UxjFkLHAm+I9o15INjF/TrHtlzkzzS9jiek" +
|
"godhUuM4eVxXQUcDNdAgSkKFt9T5WRXg2cjEZQyoi5DlIWLmOqixmx8OKFRQIDAQAB";
|
|
function generateRandomString () {
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
let result = ''
|
const charactersLength = characters.length
|
for (let i = 0; i < 16; i++) {
|
result += characters.charAt(Math.floor(Math.random() * charactersLength))
|
}
|
return result
|
}
|
|
export const generateRandomObj = generateRandomString()
|
// 调用函数生成随机字符串
|
const encryptor = new JSEncrypt() // 创建加密对象实例
|
// console.log(publicKey)
|
encryptor.setPublicKey(publicKey) // 设置公钥
|
export const rsaPassWord = encryptor.encrypt(generateRandomObj)
|