Skip to content

Commit 3c53700

Browse files
committed
'initial'
0 parents  commit 3c53700

File tree

9 files changed

+2321
-0
lines changed

9 files changed

+2321
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
node_modules/

README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Node-RSA
2+
3+
Pure JavaScript Node.js RSA library
4+
No needed OpenSSL
5+
6+
Based on jsbn library from Tom Wu http://www-cs-students.stanford.edu/~tjw/jsbn/ and node.js adaptation https://github.com/eschnou/node-bignumber
7+
8+
## Building and Installing
9+
10+
```shell
11+
npm install node-rsa
12+
```
13+
14+
#### Testing
15+
16+
```shell
17+
npm test
18+
```
19+
20+
## Usage
21+
22+
### Create instance
23+
#### "Empty" key
24+
```js
25+
var key = new NodeRSA();
26+
```
27+
28+
### Generate new key 512bit-length and with public exponent 65537
29+
```js
30+
var key = NodeRSA({b: 512});
31+
```
32+
33+
### Load key from PEM string
34+
35+
```js
36+
var key = new NodeRSA('-----BEGIN RSA PRIVATE KEY-----\n'+
37+
'MIIBOQIBAAJAVY6quuzCwyOWzymJ7C4zXjeV/232wt2ZgJZ1kHzjI73wnhQ3WQcL\n'+
38+
'DFCSoi2lPUW8/zspk0qWvPdtp6Jg5Lu7hwIDAQABAkBEws9mQahZ6r1mq2zEm3D/\n'+
39+
'VM9BpV//xtd6p/G+eRCYBT2qshGx42ucdgZCYJptFoW+HEx/jtzWe74yK6jGIkWJ\n'+
40+
'AiEAoNAMsPqwWwTyjDZCo9iKvfIQvd3MWnmtFmjiHoPtjx0CIQCIMypAEEkZuQUi\n'+
41+
'pMoreJrOlLJWdc0bfhzNAJjxsTv/8wIgQG0ZqI3GubBxu9rBOAM5EoA4VNjXVigJ\n'+
42+
'QEEk1jTkp8ECIQCHhsoq90mWM/p9L5cQzLDWkTYoPI49Ji+Iemi2T5MRqwIgQl07\n'+
43+
'Es+KCn25OKXR/FJ5fu6A6A+MptABL3r8SEjlpLc=\n'+
44+
'-----END RSA PRIVATE KEY-----');
45+
```
46+
47+
Also you can use next methods:
48+
49+
```js
50+
key.generateKeyPair(bits, exp); // exp = 65537 by default
51+
key.loadFromPEM();
52+
```
53+
54+
### Export keys
55+
```js
56+
key.toPrivatePEM();
57+
key.toPublicPEM();
58+
```
59+
60+
### Test key
61+
```js
62+
key.isPrivate();
63+
key.isPublic();
64+
```
65+
66+
67+
## Contributing
68+
69+
Questions, comments, bug reports, and pull requests are all welcome.
70+
71+
## License For NodeRSA.js
72+
73+
BSD
74+
75+
## Licensing For Code used in rsa.js and jsbn.js
76+
77+
Copyright (c) 2003-2005 Tom Wu
78+
All Rights Reserved.
79+
80+
Permission is hereby granted, free of charge, to any person obtaining
81+
a copy of this software and associated documentation files (the
82+
"Software"), to deal in the Software without restriction, including
83+
without limitation the rights to use, copy, modify, merge, publish,
84+
distribute, sublicense, and/or sell copies of the Software, and to
85+
permit persons to whom the Software is furnished to do so, subject to
86+
the following conditions:
87+
88+
The above copyright notice and this permission notice shall be
89+
included in all copies or substantial portions of the Software.
90+
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
91+
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
92+
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
93+
94+
IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
95+
INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
96+
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
97+
THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
98+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
99+
100+
In addition, the following condition applies:
101+
102+
All redistributions must retain an intact copy of this copyright notice
103+
and disclaimer.

gruntfile.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module.exports = function(grunt) {
2+
grunt.initConfig({
3+
jshint: {
4+
options: {
5+
},
6+
default: {
7+
files: {
8+
src: ['src/**/*.js', '!src/libs/**/*']
9+
}
10+
},
11+
libs: {
12+
files: {
13+
src: ['src/libs/**/*']
14+
}
15+
}
16+
},
17+
18+
simplemocha: {
19+
options: {
20+
reporter: 'List'
21+
},
22+
all: { src: ['test/**/*.js'] }
23+
}
24+
});
25+
26+
require('jit-grunt')(grunt, {
27+
'simplemocha': 'grunt-simple-mocha'
28+
});
29+
30+
31+
grunt.registerTask('lint', ['jshint:default']);
32+
grunt.registerTask('test', ['simplemocha']);
33+
34+
grunt.registerTask('default', ['lint', 'test']);
35+
}

package.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "node-rsa",
3+
"version": "0.0.1",
4+
"description": "Node.js RSA library",
5+
"main": "dist/nodersa.js",
6+
"scripts": {
7+
"test": "grunt test",
8+
"install": "grunt"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/rzcoder/node-rsa.git"
13+
},
14+
"keywords": [
15+
"node.js",
16+
"rsa"
17+
],
18+
"author": "rzcoder",
19+
"license": "BSD",
20+
"bugs": {
21+
"url": "https://github.com/rzcoder/node-rsa/issues"
22+
},
23+
"homepage": "https://github.com/rzcoder/node-rsa",
24+
"devDependencies": {
25+
"grunt": "^0.4.4",
26+
"grunt-simple-mocha": "^0.4.0",
27+
"jit-grunt": "^0.3.2",
28+
"chai": "^1.9.1",
29+
"grunt-contrib-jshint": "^0.9.2"
30+
},
31+
"dependencies": {
32+
"lodash": "^2.4.1",
33+
"asn1": "^0.2.0"
34+
}
35+
}

0 commit comments

Comments
 (0)