Skip to content

Instantly share code, notes, and snippets.

bartt / onename
Created Nov 13, 2014
Onename Verification
View onename
Verifying that +bartt is my openname (Bitcoin username).

Keybase proof

I hereby claim:

  • I am bartt on github.
  • I am bartt ( on keybase.
  • I have a public key whose fingerprint is C199 03BF 9764 A180 A8FF F91F 3FE9 490F F750 DA44

To claim this, I am signing this object:

View gist:667031
var fs = require('fs');
// Start with a binary file
fs.readFile('foo.jpg', function(err, data){
// Write as base64 encoded text
fs.writeFile('foo.txt', data.toString('base64'), function(err){
// Read the base64 encoded file back in.
fs.readFile('foo.txt', function(err, data){
// Write back out as binary data
fs.writeFile('bar.jpg', data, 'base64', function(err){
View gist:666928
var fs = require('fs');
fs.readFile('some-image.jpg', function(err, data){
// Does write base64 encoded data
fs.writeFile('some-image1.txt', data.toString('base64'), function(err){})
// Does NOT write base64 encoded data. The file is identical to some-image.jpg
fs.writeFile('some-image2.txt', data, 'base64', function(err){});
bartt / gist:663052
Created Nov 4, 2010
Hmac digest only returns a digest once?
View gist:663052
crypto = require('crypto');
hmac = crypto.createHmac('sha256', 'hackme');
hmac.digest('hex'); // '6a405c5f6fe96680a57054cee8a4a74356c2df1b5e5cf8102dac3773af713418'
hmac.digest('hex'); // '' -- Hûh?!
hmac.digest('hex'); // '' -- Hûh?! Again?