Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including pem-jwk with all npm packages installed. Try it out:

var pemJwk = require("pem-jwk")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

pem-jwk v2.0.0

convert between PEM and JWK formats

pem-jwk

convert between PEM and JWK key serialization formats

Usage

As a commandline tool:

$ npm install -g pem-jwk
$ openssl genrsa 2048 | pem-jwk > private.jwk
$ pem-jwk private.jwk > private.pem

Example

var assert = require('assert')
var fs = require('fs')
var pem2jwk = require('pem-jwk').pem2jwk
var jwk2pem = require('pem-jwk').jwk2pem

var str = fs.readFileSync('./test/priv.pem', 'ascii')
var jwk = pem2jwk(str)
var pem = jwk2pem(jwk)
assert.equal(pem, str)
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free