这是可行的:
import NodeRSA from 'node-rsa';
const myPrivateKey = '........';
const key = new NodeRSA(myPrivateKey);
const message = '1234567890';
var encrypted = key.encrypt(message, 'base64', 'utf-8');
var clearMessage = key.decrypt(encrypted, 'utf8'); // contains '1234567890'我认为RSA使用公钥加密,使用私钥解密。但是在上面的代码中,我似乎从来不需要给NodeRSA我的公钥。
我遗漏了什么?
发布于 2020-09-06 05:30:02
对于RSA,公钥通常是私钥的子集。如果您要导入私钥,那么公钥将包含的所有字段都在那里,并且可以使用。
https://stackoverflow.com/questions/63758488
复制相似问题