Skip to content

Instantly share code, notes, and snippets.

@bartt
bartt / onename
Created November 13, 2014 20:40
Onename Verification
Verifying that +bartt is my openname (Bitcoin username). https://onename.io/bartt

Keybase proof

I hereby claim:

  • I am bartt on github.
  • I am bartt (https://keybase.io/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:

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){
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
bartt / gist:663052
Created November 4, 2010 19:40
Hmac digest only returns a digest once?
crypto = require('crypto');
hmac = crypto.createHmac('sha256', 'hackme');
hmac.update('bladibla');
hmac.digest('hex'); // '6a405c5f6fe96680a57054cee8a4a74356c2df1b5e5cf8102dac3773af713418'
hmac.digest('hex'); // '' -- Hûh?!
hmac.update('bladibla');
hmac.digest('hex'); // '' -- Hûh?! Again?