This commit is contained in:
2025-02-18 08:31:38 +08:00
parent b6a71aa49b
commit cf1cc83547
12 changed files with 104 additions and 52 deletions

View File

@@ -7,6 +7,15 @@ class Rsa {
constructor() {
this.private_key = this.readFiles(this.getFilePath(config.rsa.private_key))
this.public_key = this.readFiles(this.getFilePath(config.rsa.public_key))
this.pri_rsa = new NodeRsa(this.private_key,'pkcs8-private-pem')
this.pri_rsa.setOptions({ encryptionScheme: 'pkcs1' })
this.pri_rsa.setOptions({ environment: "browser" });
this.pub_rsa = new NodeRsa(this.public_key,'pkcs8-public-pem')
this.pub_rsa.setOptions({ encryptionScheme: 'pkcs1' })
this.pub_rsa.setOptions({ environment: "browser" });
}
@@ -28,7 +37,7 @@ class Rsa {
// 私钥解密
PrivateKeyDecryption(text) {
return JSON.parse((new NodeRsa(this.private_key)).decrypt(text, 'utf8'))
return JSON.parse(this.pri_rsa.decrypt(text, 'utf8'))
}
/**