Skip to content

Commit

Permalink
Merge pull request brix#148 from thg303/improve-documentation
Browse files Browse the repository at this point in the history
improve documentation
  • Loading branch information
evanvosberg authored Sep 13, 2018
2 parents 73c20dd + 3e4f8f6 commit 31efd5b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ See: https://code.google.com/p/crypto-js
var CryptoJS = require("crypto-js");

// Encrypt
var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123');
var cipherText = CryptoJS.AES.encrypt('my message', 'secret key 123').toString();

// Decrypt
var bytes = CryptoJS.AES.decrypt(ciphertext.toString(), 'secret key 123');
var plaintext = bytes.toString(CryptoJS.enc.Utf8);
var bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
var originalText = bytes.toString(CryptoJS.enc.Utf8);

console.log(plaintext);
console.log(originalText); // 'my message'
```

#### Object encryption
Expand All @@ -128,13 +128,13 @@ var CryptoJS = require("crypto-js");
var data = [{id: 1}, {id: 2}]

// Encrypt
var ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123');
var ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123').toString();

// Decrypt
var bytes = CryptoJS.AES.decrypt(ciphertext.toString(), 'secret key 123');
var bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
var decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));

console.log(decryptedData);
console.log(decryptedData); // [{id: 1}, {id: 2}]
```

### List of modules
Expand Down

0 comments on commit 31efd5b

Please sign in to comment.