Skip to content

Instantly share code, notes, and snippets.

View Honigbaum's full-sized avatar

Torben Honigbaum Honigbaum

  • neuland bremen GmbH
  • Deutschland
View GitHub Profile
var crypto = require("crypto");
var inputVector = new Buffer("c1234567-zipl-03");
var secretKeyHash = new Buffer("GeN8IfCrdxKxMxFA");
var cipher = crypto.createCipheriv('AES-128-CBC', secretKeyHash, inputVector);
cipher.update("Test", 'binary', 'binary');
var encryptedHexNumber = cipher.final('hex');
return "1" + encryptedHexNumber
@Honigbaum
Honigbaum / gist:3782352
Created September 25, 2012 14:44
Encryption
IvParameterSpec ivSpec = new IvParameterSpec("c1234567-zipl-03".getBytes());
SecretKeySpec keySpec = new SecretKeySpec("GeN8IfCrdxKxMxFA".getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec);
return "1" + bytesToHex(cipher.doFinal("Test".getBytes()));
domain = require("domain")
express = require("express")
workerDomain = domain.create()
workerDomain.on "error", (err) ->
Log.error(err)
// Here I wan't to render an error page
workerDomain.run () ->
server = express()
cluster = require("cluster")
domain = require("domain")
express = require("express")
os = require("os")
if cluster.isMaster
cluster.fork() for cpu in os.cpus()
// Fork new worker if one dies
else