0.2.4 • Published 5 years ago

simple-pem2jwk v0.2.4

Weekly downloads
14
License
Apache-2.0
Repository
github
Last release
5 years ago

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.

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago