Skip to content

Instantly share code, notes, and snippets.



Created Jun 15, 2011
What would you like to do?
base64 cipher fix
// a shim to fix base64 cipher output, untested
var Cipher = require('crypto').Cipher;
var update = Cipher.prototype.update,
final =;
Cipher.prototype.update = function(data, input, output) {
if (output === 'base64') {
data =, data, input, 'binary');
return new Buffer(data, 'binary').toString('base64');
return update.apply(this, arguments);
}; = function(output) {
if (output === 'base64') {
var data =, 'binary');
if (!data) return data;
return new Buffer(data, 'binary').toString('base64');
return final.apply(this, arguments);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.