Skip to content

Instantly share code, notes, and snippets.

@lsm
lsm / long-string-cipher-base64.js
Created October 29, 2010 15:46
long string cipher->base64 and decipher
var c = require('crypto');
// cipher to binary
var cipher = c.createCipher('aes192', 'hello');
var en = cipher.update('你好你好你好你好你好dfferfdgwefdv4t5g56euhergy56yhe54wtfgq34tg你好你好你好你好你好你好你好erwgw43etr', 'utf8', 'binary') + cipher.final('binary');
console.log(en);
// binary to base64
var buff = new Buffer(en, 'binary');
var base64 = buff.toString('base64');
function() {
var me = this,
writeHead = me.flaker.writeHead,
write = me.flaker.write,
contentType = mime.lookup(extname(filePath));
fs.stat(filePath, function(err, stat) {
if (err || !stat.isFile()) {
errback ? errback(err) : me.error(404, 'File not found');
return;
}
var Pool = Base(EventEmitter, {
init: function(getConnection, size) {
this._super();
this._pool = [];
this._queue = [];
this.size = size;
var me = this;
getConnection(size, function(conn) {
me.emit('back', conn);
});