@@ -5,8 +5,9 @@ Modularized port of googlecode project crypto-js.
5
5
## Node.js (Install)
6
6
7
7
Requirements:
8
- * Node.js
9
- * npm (Node.js package manager)
8
+
9
+ - Node.js
10
+ - npm (Node.js package manager)
10
11
11
12
``` bash
12
13
npm install crypto-js
@@ -15,6 +16,7 @@ npm install crypto-js
15
16
### Usage
16
17
17
18
Modular include:
19
+
18
20
``` javascript
19
21
var AES = require (" crypto-js/aes" );
20
22
var SHA256 = require (" crypto-js/sha256" );
@@ -23,29 +25,67 @@ console.log(SHA256("Message"));
23
25
```
24
26
25
27
Including all libraries, for access to extra methods:
28
+
26
29
``` javascript
27
30
var CryptoJS = require (" crypto-js" );
28
31
console .log (CryptoJS .HmacSHA1 (" Message" , " Key" ));
29
32
```
30
33
31
34
## Client (browser)
32
35
36
+ Requirements:
37
+
38
+ - Node.js
39
+ - Bower (package manager for frontend)
40
+
41
+ ``` bash
42
+ bower install crypto-js
43
+ ```
44
+
33
45
### Usage
34
46
35
47
Modular include:
48
+
36
49
``` javascript
50
+ require .config ({
51
+ packages: [
52
+ {
53
+ name: ' crypto-js' ,
54
+ location: ' path-to/bower_components/crypto-js' ,
55
+ main: ' index'
56
+ }
57
+ ]
58
+ });
59
+
37
60
require ([" crypto-js/aes" , " crypto-js/sha256" ], function (AES , SHA256 ) {
38
61
console .log (SHA256 (" Message" ));
39
62
});
40
63
```
41
64
42
65
Including all libraries, for access to extra methods:
66
+
43
67
``` javascript
44
- require (" crypto-js" , function (CryptoJS ) {
68
+ // Above-mentioned will work or use this simple form
69
+ require .config ({
70
+ paths: {
71
+ ' require-js' : ' path-to/bower_components/crypto-js/crypto-js'
72
+ }
73
+ });
74
+
75
+ require ([" crypto-js" ], function (CryptoJS ) {
45
76
console .log (CryptoJS .HmacSHA1 (" Message" , " Key" ));
46
77
});
47
78
```
48
79
80
+ ### Usage without RequireJS
81
+
82
+ ``` html
83
+ <script type =" text/javascript" src =" path-to/bower_components/crypto-js/crypto-js.js" ></script >
84
+ <script type =" text/javascript" >
85
+ var encrypted = CryptoJS .AES (... );
86
+ var encrypted = CryptoJS .SHA256 (... );
87
+ </script >
88
+
49
89
## API
50
90
51
91
See: https://code.google.com/p/crypto-js
@@ -122,17 +162,6 @@ See: https://code.google.com/p/crypto-js
122
162
- ```crypto-js/pad-zeropadding```
123
163
- ```crypto-js/pad-nopadding```
124
164
125
- ## Contribution
126
-
127
- ### Git Flow
128
-
129
- The crypto-js project uses [ git flow] ( https://github.com/nvie/gitflow ) to manage branches.
130
- Do your changes on the ` develop ` or even better on a ` feature/* ` branch. Don't do any changes on the ` master ` branch.
131
-
132
- ### Pull request
133
-
134
- Target your pull request on ` develop ` branch. Other pull request won't be accepted.
135
-
136
165
## License
137
166
138
167
[The MIT License (MIT)](http://opensource.org/licenses/MIT)
0 commit comments