# simple-pem2jwk

> Parse PEM to JWK format with minimal dependencies

Latest version **0.2.4** (published 2019-05-22) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install simple-pem2jwk
pnpm add simple-pem2jwk
yarn add simple-pem2jwk
bun add simple-pem2jwk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2019-05-22 |
| First published | 2019-05-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 24.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Einar Persson |
| Maintainers | einarpersson |
| Keywords | react-native, pem, jwk, rsa |

## Links

- npm: https://www.npmjs.com/package/simple-pem2jwk
- Repository: https://github.com/einarpersson/simple-pem2jwk
- Homepage: https://github.com/einarpersson/simple-pem2jwk#readme
- Issues: https://github.com/einarpersson/simple-pem2jwk/issues
- npm.io page: https://npm.io/package/simple-pem2jwk

## Dependencies (3)

- [asn1js](https://npm.io/package/asn1js.md) ^2.0.22
- [buffer](https://npm.io/package/buffer.md) ^5.2.1
- [js-base64](https://npm.io/package/js-base64.md) ^2.5.1

## Recent versions

- 0.2.4 (latest) — 2019-05-22
- 0.2.3 — 2019-05-22
- 0.2.2 — 2019-05-13
- 0.2.1 — 2019-05-13
- 0.2.0 — 2019-05-13
- 0.1.1 — 2019-05-13

## README

# simple-pem2jwk

Simple RSA key conversion from PEM-format to JWK-format with no dependencies on [Node.js](https://nodejs.org/) or [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/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](https://tools.ietf.org/html/rfc7518#section-6.3).

## Why this lib?
The lib [react-native-rsa-native](https://github.com/amitaymolko/react-native-rsa-native) generates keys in PEM format but did not support exporting to JWK format. Hence this helper lib.

---
_Source: https://npm.io/package/simple-pem2jwk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
