Skip to content

Instantly share code, notes, and snippets.

@indexzero
Forked from isaacs/buffer-to-from-string.js
Created October 24, 2010 00:47
Show Gist options
  • Save indexzero/642909 to your computer and use it in GitHub Desktop.
Save indexzero/642909 to your computer and use it in GitHub Desktop.
var b = new Buffer(256*256)
for (var i = 0 ; i < 256*256 ; i ++) {
b[i] = i % 256
}
var s = b.toString("binary")
var b2 = new Buffer(s, "binary")
for (var i = 0 ; i < 256*256 ; i ++) {
if (b2[i] !== i) console.error("error at 0x"+i.toString(16))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment