You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
643 B

1 year ago
const JSEncrypt = require('./jsencrypt.min.js');
// 支付密码加密
// 公钥
const keyPub = "-----BEGIN PUBLIC KEY-----\n" +
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC1yLtKwRwC/Uv35920h7X4on8/\n"+
"hR8AuYnWOsyDCGbepY+1cMhSX2zOu8BUINk5UcwIbm62Ki7xZIWT9+1Wn0y7dfJb\n"+
"kub5O6/lM3oHuY7eT9alYs5kw8EWsznT/zeE9sapTJyPVDhRuFwslEayzPhx6lVR\n"+
"6lwfQTK/gfUtz8gbxwIDAQAB\n"+
"-----END PUBLIC KEY-----\n"
const handleEncrypt = (str) => {
const jsencrypt = new JSEncrypt();
jsencrypt.setPublicKey(keyPub); // 设置公钥
return jsencrypt.encrypt(str); // 对数据进行加密
}
module.exports = {
handleEncrypt: handleEncrypt,
}