javascript - Node.js proxy request and encrypt it using AES -


what easiest way in express app code route proxies request server , encrypts response before sending client (where decrypted). possible using streams?

var request = require('request'),     http = require('http'),     crypto = require('crypto'),     acceptor = http.createserver().listen(8089);  acceptor.on('request', function(r, s) {     var ciph = crypto.createcipher('aes192', 'mypassword');      // simple stream object convert binary string     var transform = require('stream').transform;     var btostr = new transform({decodestrings: false});     btostr._transform = function(chunk, encoding, done) {        done(null, chunk.tostring('base64'));     };      // html goog, made more dynamic     request('http://google.com').pipe(ciph).pipe(btostr).pipe(s);       //  try encrypt & decrypt verify works, print cleartext stdout     //var decrypt = crypto.createdecipher('aes192', 'mypassword');     //request('http://google.com').pipe(ciph).pipe(decrypt).pipe(process.stdout); }) 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -