Skip to content

Instantly share code, notes, and snippets.

@refack
Last active August 29, 2015 14:01
Show Gist options
  • Save refack/ca56082bc653b456ecfb to your computer and use it in GitHub Desktop.
Save refack/ca56082bc653b456ecfb to your computer and use it in GitHub Desktop.
var assert = require('assert');
var crypto = require('crypto');
var EXTERN_APEX = 0xFBEE9;
var ucs2_control = 'a\u0000';
while (ucs2_control.length <= EXTERN_APEX) {
ucs2_control += ucs2_control;
}
var b1 = new Buffer(ucs2_control, 'ucs2').slice(900000);
var b2 = new Buffer(ucs2_control, 'ucs2').slice(900000);
// #### mutating b2 above the blind spot ####
var i = b2.length;
function mutate() {
i -= 1000;
if (i < 0) return;
b2[i] = 255 - b2[i];
var hash1_converted2 = crypto.createHash('sha1')
.update(b1.toString('base64'), 'base64')
.digest('hex');
var hash2_converted2 = crypto.createHash('sha1')
.update(b2.toString('base64'), 'base64')
.digest('hex');
console.log("%d - %s vs %s", i, hash1_converted2, hash2_converted2);
if (hash1_converted2 != hash2_converted2) {
console.error('should not have hashed the same while different above the index ' + i);
i = -1;
}
setImmediate(mutate);
}
setImmediate(mutate);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment