MrShi
2025-08-19 30e858fa504b268b9b436afca0a1259cf6e8c488
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// 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)