我正在使用Web Crypto API并使用generateKey函数生成RSA 密钥对。由于我的代码中存在一些错误,我删除了一些用户的公钥。我想知道是否有任何方法可以从私钥生成公钥?我知道这对于 ssh 密钥来说很容易实现。这是我生成 RSA 密钥对的示例代码:
const generateRSAKeys = (): Promise<CryptoKeyPair> => {
return crypto.subtle.generateKey(
{
name: 'RSA-OAEP',
modulusLength: 2048
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
hash: { name: 'SHA-512' },
},
true,
['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'],
);
Run Code Online (Sandbox Code Playgroud) javascript encryption rsa encryption-asymmetric webcrypto-api