Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ppbntl19 opened this issue Dec 16, 2016 · 2 comments
Open

Comments

@ppbntl19
Copy link

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

@NaLLiFFuNT
Copy link

Any updates?

@ppbntl19
Copy link
Author

ppbntl19 commented Feb 7, 2019

@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
        };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants