钟铮锁App web部分 需要打包放进对应的安卓项目 生成apk 才能正常使用功能
he wei
2024-12-20 552a8341d159e463e2946074e21deddb185c90ee
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
29
30
31
32
33
import {JSEncrypt} from "jsencrypt";
import const_num from "@/assets/js/const/const_num";
// import const_num from "@/assets/js/const/const_key";
 
export default {
  /**
   * 非对称加密算法-加密
   * @param word  需要加密的字符串
   * @returns {string | false}
   */
  encrypt(word) {
    let encryptor = new JSEncrypt();
    let publicKey = const_num.publicKey;
    encryptor.setPublicKey(publicKey);
    let rsaPassWord = encryptor.encrypt(word);
    return rsaPassWord;
  },
  /**
   * 非对称加密算法-解密
   * @param word
   * @param privateKey
   * @returns {string | false}
   */
  decrypt(word, privateKey) {
    if(!privateKey) {
      return "请写入私钥";
    }
    let decrypt = new JSEncrypt();
    decrypt.setPrivateKey(privateKey);
    let getWord = decrypt.decrypt(word);
    return getWord;
  }
}