Skip to content

Commit 507be4a

Browse files
committed
Update README.md
1 parent 4474665 commit 507be4a

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

README.md

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ var NodeRSA = require('node-rsa');
4949
var key = new NodeRSA([keyData, [format]], [options]);
5050
```
5151

52-
* **keyData**`{string|buffer|object}` — parameters for generating key or the key in one of supported formats.<br/>
53-
* **format**`{string}` — format for importing key. See more details about formats in [Export/Import](#importexport-keys) section.<br/>
54-
* **options**`{object}` — additional settings.
52+
* keyData — `{string|buffer|object}` — parameters for generating key or the key in one of supported formats.<br/>
53+
* format — `{string}` — format for importing key. See more details about formats in [Export/Import](#importexport-keys) section.<br/>
54+
* options — `{object}` — additional settings.
5555

5656
#### Options
5757
You can specify some options by second/third constructor argument, or over `key.setOptions()` method.
5858

59-
* **environment** — working environment, `'browser'` or `'node'`. Default autodetect.
60-
* **encryptionScheme** — padding scheme for encrypt/decrypt. Can be `'pkcs1_oaep'` or `'pkcs1'`. Default `'pkcs1_oaep'`.
61-
* **signingScheme** — scheme used for signing and verifying. Can be `'pkcs1'` or `'pss'` or 'scheme-hash' format string (eg `'pss-sha1'`). Default `'pkcs1-sha256'`, or, if chosen pss: `'pss-sha1'`.
59+
* environment — working environment, `'browser'` or `'node'`. Default autodetect.
60+
* encryptionScheme — padding scheme for encrypt/decrypt. Can be `'pkcs1_oaep'` or `'pkcs1'`. Default `'pkcs1_oaep'`.
61+
* signingScheme — scheme used for signing and verifying. Can be `'pkcs1'` or `'pss'` or 'scheme-hash' format string (eg `'pss-sha1'`). Default `'pkcs1-sha256'`, or, if chosen pss: `'pss-sha1'`.
6262

6363
**Advanced options:**<br/>
6464
You also can specify advanced options for some schemes like this:
@@ -95,8 +95,8 @@ Also you can use next method:
9595
key.generateKeyPair([bits], [exp]);
9696
```
9797

98-
* **bits**`{int}` — key size in bits. 2048 by default.
99-
* **exp**`{int}` — public exponent. 65537 by default.
98+
* bits — `{int}` — key size in bits. 2048 by default.
99+
* exp — `{int}` — public exponent. 65537 by default.
100100

101101
#### Load key from PEM string
102102

@@ -118,19 +118,19 @@ key.importKey(keyData, [format]);
118118
key.exportKey([format]);
119119
```
120120

121-
* **keyData**`{string|buffer}` — key in PEM string **or** Buffer contains PEM string **or** Buffer contains DER encoded data.
122-
* **format**`{string}` — format id for export/import.
121+
* keyData — `{string|buffer}` — key in PEM string **or** Buffer contains PEM string **or** Buffer contains DER encoded data.
122+
* format — `{string}` — format id for export/import.
123123

124124
#### Format string syntax
125125
Format string composed of several parts: `scheme-[key_type]-[output_type]`<br/>
126126

127-
**Scheme** — NodeRSA supports multiple format schemes for import/export keys:
127+
Scheme — NodeRSA supports multiple format schemes for import/export keys:
128128

129129
* `'pkcs1'` — public key starts from `'-----BEGIN RSA PUBLIC KEY-----'` header and private key starts from `'-----BEGIN RSA PRIVATE KEY-----' header`
130130
* `'pkcs8'` — public key starts from `'-----BEGIN PUBLIC KEY-----'` header and private key starts from `'-----BEGIN PRIVATE KEY-----' header`
131131

132-
**Key type** — can be `'private'` or `'public'`. Default `'private'`<br/>
133-
**Output type** — can be:
132+
Key type — can be `'private'` or `'public'`. Default `'private'`<br/>
133+
Output type — can be:
134134

135135
* `'pem'` — Base64 encoded string with header and footer. Used by default.
136136
* `'der'` — Binary encoded key data.
@@ -160,7 +160,7 @@ var privateDer = key.exportKey('pkcs1-der');
160160
key.isPrivate();
161161
key.isPublic([strict]);
162162
```
163-
**strict**`{boolean}` if true method will return false if key pair have private exponent. Default `false`.
163+
strict — `{boolean}` if true method will return false if key pair have private exponent. Default `false`.
164164

165165
```javascript
166166
key.isEmpty();
@@ -184,16 +184,18 @@ Return max data size for encrypt in bytes.
184184
key.encrypt(buffer, [encoding], [source_encoding]);
185185
```
186186
Return encrypted data.<br/>
187-
**buffer** - data for encrypting, may be string, Buffer, or any object/array. Arrays and objects will encoded to JSON string first.<br/>
188-
**encoding** - encoding for output result, may be `'buffer'`, `'binary'`, `'hex'` or `'base64'`. Default `'buffer'`.<br/>
189-
**source_encoding** - source encoding, works only with string buffer. Can take standard Node.js Buffer encodings (hex, utf8, base64, etc). `'utf8'` by default.<br/>
187+
188+
* buffer — `{buffer}` — data for encrypting, may be string, Buffer, or any object/array. Arrays and objects will encoded to JSON string first.<br/>
189+
* encoding — `{string}` — encoding for output result, may be `'buffer'`, `'binary'`, `'hex'` or `'base64'`. Default `'buffer'`.<br/>
190+
* source_encoding — `{string}` — source encoding, works only with string buffer. Can take standard Node.js Buffer encodings (hex, utf8, base64, etc). `'utf8'` by default.<br/>
190191

191192
```javascript
192193
key.decrypt(buffer, [encoding]);
193194
```
194195
Return decrypted data.<br/>
195-
**buffer** - data for decrypting. Takes Buffer object or base64 encoded string.<br/>
196-
**encoding** - encoding for result string. Can also take `'buffer'` for raw Buffer object, or `'json'` for automatic JSON.parse result. Default `'buffer'`.
196+
197+
* buffer — `{buffer}` — data for decrypting. Takes Buffer object or base64 encoded string.<br/>
198+
* encoding — `{string}` — encoding for result string. Can also take `'buffer'` for raw Buffer object, or `'json'` for automatic JSON.parse result. Default `'buffer'`.
197199

198200
### Signing/Verifying
199201
```javascript
@@ -205,10 +207,11 @@ Return signature for buffer. All the arguments are the same as for `encrypt` met
205207
key.verify(buffer, signature, [source_encoding], [signature_encoding])
206208
```
207209
Return result of check, `true` or `false`.<br/>
208-
**buffer** - data for check, same as `encrypt` method.<br/>
209-
**signature** - signature for check, result of `sign` method.<br/>
210-
**source_encoding** - same as for `encrypt` method.<br/>
211-
**signature_encoding** - encoding of given signature. May be `'buffer'`, `'binary'`, `'hex'` or `'base64'`. Default `'buffer'`.
210+
211+
* buffer — `{buffer}` — data for check, same as `encrypt` method.<br/>
212+
* signature — `{string}` — signature for check, result of `sign` method.<br/>
213+
* source_encoding — `{string}` — same as for `encrypt` method.<br/>
214+
* signature_encoding — `{string}` — encoding of given signature. May be `'buffer'`, `'binary'`, `'hex'` or `'base64'`. Default `'buffer'`.
212215

213216
## Contributing
214217

@@ -217,7 +220,8 @@ Questions, comments, bug reports, and pull requests are all welcome.
217220
## Changelog
218221

219222
### 0.2.10
220-
* **Methods `.exportPrivate()` and `.exportPublic()` was replaced by `.exportKey([format])`. By default `.exportKey()` returns private key as `.exportPrivate()`, if you need public key from `.exportPublic()` you must specify format as `'public'` or `'pkcs8-public-pem'`.**
223+
* **Methods `.exportPrivate()` and `.exportPublic()` was replaced by `.exportKey([format])`.**
224+
* By default `.exportKey()` returns private key as `.exportPrivate()`, if you need public key from `.exportPublic()` you must specify format as `'public'` or `'pkcs8-public-pem'`.
221225
* Method `.importKey(key, [format])` now has second argument.
222226

223227
### 0.2.0

0 commit comments

Comments
 (0)