simple-pem2jwk
v0.2.4
Published
Parse PEM to JWK format with minimal dependencies
Downloads
440
Readme
simple-pem2jwk
Simple RSA key conversion from PEM-format to JWK-format with no dependencies on Node.js or Web Crypto API. Works in react-native.
Example for private key;
const privateKey = `-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCA... ...e+BMRbC5SnJpMsfF0luZhvX
-----END RSA PRIVATE KEY-----`
pem2jwk(privateKey)
// Output:
// {
// p: '...',
// kty: 'RSA',
// q: '...',
// d: '...',
// e: '...',
// qi: '...',
// dp: '...',
// dq: '...',
// n: '...'
// }
// It works the same way with public keys but the output only contains parameters n, e and kty
What does the parameters mean?
Read section 6.3 in rfc7518.
Why this lib?
The lib react-native-rsa-native generates keys in PEM format but did not support exporting to JWK format. Hence this helper lib.