Last active
May 18, 2016 18:58
-
-
Save ccapndave/4eaee7b27248343c991e64dad9912f62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch("http://localhost:3000/content/encrypted.json") | |
.then(res => res.text()) | |
.then(x => cjs.AES.decrypt(x, "iamapassword") | |
.toString(cjs.enc.Utf8)) | |
.then(decryptedTxt => console.log(decryptedTxt)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=��"I | |
�_��Ԃ�ȓ | |
��F�ZXcX�$�" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stream = fs.createReadStream(fullPath); | |
stream.on('error', err => { | |
res.status(404).send("Content not found"); | |
res.end(); | |
}); | |
// create encryption stream | |
const encrypt = crypto.createCipher("aes-256-ctr", "iamapassword"); | |
stream.pipe(encrypt).pipe(res); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
txt: "Can you decode me?" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment