corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 cryptojs
2 --------
3  
4 * with little modification, converted from googlecode project [crypto-js](http://code.google.com/p/crypto-js/), and keep the source code structure of the origin project on googlecode
5 * source code worked in both browser engines and node scripts. see also: [https://github.com/gwjjeff/crypto-js-npm-conv](https://github.com/gwjjeff/crypto-js-npm-conv)
6 * inspiration comes from [ezcrypto](https://github.com/ElmerZhang/ezcrypto), but my tests cannot pass with his version ( ECB/pkcs7 mode ), so I made it myself
7  
8 ### install
9  
10 <pre>
11 npm install cryptojs
12 </pre>
13  
14 ### usage (example with [coffee-script](http://coffeescript.org/))
15  
16 <pre>
17 Crypto = (require 'cryptojs').Crypto
18 key = '12345678'
19 us = 'Hello, 世界!'
20  
21 mode = new Crypto.mode.ECB Crypto.pad.pkcs7
22  
23 ub = Crypto.charenc.UTF8.stringToBytes us
24 eb = Crypto.DES.encrypt ub, key, {asBytes: true, mode: mode}
25 ehs= Crypto.util.bytesToHex eb
26  
27 eb2= Crypto.util.hexToBytes ehs
28 ub2= Crypto.DES.decrypt eb2, key, {asBytes: true, mode: mode}
29 us2= Crypto.charenc.UTF8.bytesToString ub2
30 # should be same as the var 'us'
31 console .log us2
32 </pre>