Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

RSA key serialization#3

Open
rca wants to merge 1 commit intowwwtyro:masterfrom
rca:master
Open

RSA key serialization#3
rca wants to merge 1 commit intowwwtyro:masterfrom
rca:master

Conversation

@rca
Copy link
Copy Markdown

@rca rca commented Feb 5, 2013

I didn't notice a way to serialize an RSAKey object, so I created the following.

Thoughts?

Calling key.toJSON() creates an object that is serializable with:

JSON.stringify(key.toJSON())

The RSA key can be recreated using:

RSA.parse(JSON.parse(rsaString))

Calling key.toJSON() creates an object that is serializable with:

```javascript
JSON.stringify(key.toJSON())
```

The RSA key can be recreated using:

```javascript
RSA.parse(JSON.parse(rsaString))
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing comma, the compiler.jar rejects this.

@BinaryMuse
Copy link
Copy Markdown

As implemented in this PR, RSAParse already does a JSON.parse, so the example would be:

RSA.parse(rsaString)

Took me a moment to realize this, so perhaps this note will help someone else.

@stephensprinkle-zz
Copy link
Copy Markdown

Fantastic! Thanks so much. Got stuck on this aspect in a project and this solved it.

@hawkps
Copy link
Copy Markdown

hawkps commented Mar 5, 2015

This is awesome, really helped me out! why isn't it in the official file?

@kitwalker12
Copy link
Copy Markdown

👍 This is awesome. helped me out with a case where I wanted to encrypt at one location and decrypt elsewhere without sharing the pass phrase

@simkessy
Copy link
Copy Markdown

simkessy commented Jan 3, 2016

Can we pull this in? I'd really like to store the key in my application without sharing the passphrase

@therightstuff
Copy link
Copy Markdown

are @wwwtyro and @rca interested in continuing this? i'm happy to jump in or fork and pull and maintain if not. this is really useful and all that's blocking it is an extra comma...

@beenotung
Copy link
Copy Markdown

beenotung commented Dec 9, 2017

it seems merged somehow, this PR can be clossed

@ayazzali
Copy link
Copy Markdown

coool! but its realy hard to find.

@dansgithubuser
Copy link
Copy Markdown

dansgithubuser commented Aug 9, 2019

This repo is behind the npm distribution? That's exactly the kind of thing I don't want in an npm package offering security....

edit: ended up using web crypto, I needed symmetric encryption too https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.