Skip to content

Feature request: Support create public key from components method? #24471

@belldoor

Description

@belldoor

I cannot use ursa anymore at node v10. So I'm trying to move to native crypto.
But the problem is, native crypto seems not support create public key from components.

So, why don't you support create public key from components method?


const ursa = require('ursa');

// modulus should be a base64/base64Url string
const modulus = new Buffer(modulusStr, 'base64');
// exponent should be base64/base64url
const exponent = new Buffer('AQAB', 'base64');

const pubKey = ursa.createPublicKeyFromComponents(modulus, exponent);
console.info(pubKey.toPublicPem('utf8')); 
// ------BEGIN PUBLIC KEY------
// ...
const nodeRSA = require('node-rsa');
const key = new nodeRSA();

const modulus = new Buffer(modulusStr, 'base64');
const exponent = new Buffer('AQAB', 'base64');

const pubKey = key.importKey({ n: modulus, e: exponent }, 'components-public');
console.info(pubKey.exportKey('pkcs8-public-pem'));
// ------BEGIN PUBLIC KEY------
// ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.feature requestIssues that request new features to be added to Node.js.stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions