Skip to content

einarpersson/simple-pem2jwk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Parse PEM to JWK format without dependencies

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published