You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-49Lines changed: 9 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Based on jsbn library from Tom Wu http://www-cs-students.stanford.edu/~tjw/jsbn/
8
8
* Generating keys
9
9
* Supports long messages for encrypt/decrypt
10
10
* Signing and verifying
11
-
11
+
12
12
13
13
## Example
14
14
@@ -48,48 +48,22 @@ var NodeRSA = require('node-rsa');
48
48
49
49
var key =newNodeRSA([key], [options]);
50
50
```
51
-
52
51
**key** - parameters of a generated key or the key in PEM format.<br/>
53
52
**options** - additional settings
53
+
***environment** - working environment, `'browser'` or `'node'`. Default autodetect.
54
+
***signingAlgorithm** - hash algorithm used for signing and verifying. Can be `'sha1'`, `'sha256'`, `'md5'`. Default `'sha256'`.
54
55
55
-
#### Options
56
-
You can specify some options by second constructor argument, or over `key.setOptions()` method.
57
-
58
-
***environment** - working environment, `'browser'` or `'node'`. Default autodetect.
59
-
***encryptionScheme** - padding scheme for encrypt/decrypt. Can be `'pkcs1_oaep'` or `'pkcs1'`. Default `'pkcs1_oaep'`.
60
-
***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'`.
61
-
62
-
**Advanced options:**<br/>
63
-
You also can specify advanced options for some schemes like this:
64
-
```
65
-
options = {
66
-
encryptionScheme: {
67
-
scheme: 'pkcs1_oaep', //scheme
68
-
hash: 'md5', //hash using for scheme
69
-
mgf: function(...) {...} //mask generation function
70
-
},
71
-
signingScheme: {
72
-
scheme: 'pss', //scheme
73
-
hash: 'sha1', //hash using for scheme
74
-
saltLength: 20 //salt length for pss sign
75
-
}
76
-
}
77
-
```
78
-
79
-
This lib supporting next hash algorithms: `'md5'`, `'ripemd160'`, `'sha1'`, `'sha256'`, `'sha512'` in browser and node environment and additional `'md4'`, `'sha'`, `'sha224'`, `'sha384'` in node only.
80
-
81
-
82
-
#### Creating "empty" key
56
+
#### "Empty" key
83
57
```javascript
84
58
var key =newNodeRSA();
85
59
```
86
60
87
-
####Generate new key 512bit-length and with public exponent 65537
61
+
### Generate new key 512bit-length and with public exponent 65537
88
62
```javascript
89
63
var key =newNodeRSA({b:512});
90
64
```
91
65
92
-
####Load key from PEM string
66
+
### Load key from PEM string
93
67
94
68
```javascript
95
69
var key =newNodeRSA('-----BEGIN RSA PRIVATE KEY-----\n'+
@@ -107,15 +81,15 @@ Also you can use next methods:
107
81
108
82
```javascript
109
83
key.generateKeyPair([bits], [exp]);
110
-
key.importKey(pem_string|buffer_contains_pem);
84
+
key.loadFromPEM(pem_string|buffer_contains_pem);
111
85
```
112
86
**bits** - key size in bits. 2048 by default.
113
87
**exp** - public exponent. 65537 by default.
114
88
115
89
### Export keys
116
90
```javascript
117
-
key.exportPrivate();
118
-
key.exportPublic();
91
+
key.getPrivatePEM();
92
+
key.getPublicPEM();
119
93
```
120
94
121
95
### Properties
@@ -181,20 +155,6 @@ Questions, comments, bug reports, and pull requests are all welcome.
181
155
182
156
## Changelog
183
157
184
-
### 0.2.0
185
-
***`.getPublicPEM()` method was renamed to `.exportPublic()`**
186
-
***`.getPrivatePEM()` method was renamed to `.exportPrivate()`**
187
-
***`.loadFromPEM()` method was renamed to `.importKey()`**
188
-
* Added PKCS1_OAEP encrypting/decrypting support
189
-
***PKCS1_OAEP now default scheme, you need to specify 'encryptingScheme' option to 'pkcs1' for compatibility with 0.1.x version of NodeRSA**
190
-
* Added PSS signing/verifying support
191
-
* Signing now supports `'md5'`, `'ripemd160'`, `'sha1'`, `'sha256'`, `'sha512'` hash algorithms in both environments
192
-
and additional `'md4'`, `'sha'`, `'sha224'`, `'sha384'` for nodejs env.
193
-
***`options.signingAlgorithm` was renamed to `options.signingScheme`**
194
-
* Added `encryptingScheme` option
195
-
* Property `key.options` now mark as private. Added `key.setOptions(options)` method.
196
-
197
-
198
158
### 0.1.54
199
159
* Added support for loading PEM key from Buffer (`fs.readFileSync()` output)
0 commit comments