The following code creates the HTML output for a single icon button that is added to the page. In node version 0.5.x, the key is accepted by the server when the button is clicked, but after upgrading to 0.10.x it does not work and creates a different output. No mistakes. Is the cryptoclass modified? Please note that the key, url and iv have been slightly modified to avoid publishing secure information, but are of the correct length.
var util = require('util'); var crypto = require('crypto'); var fs = require('fs'); var dateFormat = require('dateformat'); var AESCrypt = {}; AESCrypt.encrypt = function(cryptkey, iv, cleardata) { var encipher = crypto.createCipheriv('aes-256-cbc', cryptkey, iv), encryptdata = encipher.update(cleardata); encryptdata += encipher.final('binary'); encode_encryptdata = new Buffer(encryptdata, 'binary').toString('hex'); return encode_encryptdata; } function getKey(email){ var now = new Date(); var key = new Buffer("F4553ECE8E0039675E8DA176D23BD82D455BB6272B574FDD6185296432CE1AD9",'hex'), iv = new Buffer("D95897EA52A8A0C8DF231C8F2DBE59A7",'hex'), key_bin = key.toString('binary'), iv_bin = iv.toString('binary'), text = new Buffer('mystring','ascii'), text_bin = text.toString('binary'); var enc = AESCrypt.encrypt(key_bin, iv_bin, text_bin); var page = '<form method="POST" action="https://somedomain.com/AES.aspx"><input type="hidden" name="key" value="'+enc+'"/><input type="hidden" name="ouid" value="1"/><input type="submit" value="Log ine"/></form>'; return page; } if(process.argv[2]) { email = process.argv[2]; console.log(getKey(email)); } else{ console.log('Something may be wrong with your email address>') }
wdhilliard
source share