JoshKaufman / ursa

URSA - RSA public/private key OpenSSL bindings for Node.js
Other
618 stars 135 forks source link

Creating keys in an interoperable key format, such as JSON Web Key [[JWK]] #153

Open ppbntl19 opened 7 years ago

ppbntl19 commented 7 years ago

Is it possible to get keys in JSON format. ? I need to import these key on client side using web crypto.

NaLLiFFuNT commented 5 years ago

Any updates?

ppbntl19 commented 5 years ago

@NaLLiFFuNT I did this in following way..

var ursa = require('ursa');
var pem2jwk = require('pem-jwk').pem2jwk

      //Generate a fresh pair of keys
      var key = ursa.generatePrivateKey(1024, 65537);
      //Get private key
      var privkeypem = pem2jwk(key.toPrivatePem());
      //Get public keys
      var pubkeypem = pem2jwk(key.toPublicPem());
      //Add token vars
      var new_crypto_key = {
          private_key: privkeypem,
          public_key: pubkeypem
        };