Skip to content

Instantly share code, notes, and snippets.

@wombleton
Last active December 18, 2015 13:59
Show Gist options
  • Save wombleton/5793520 to your computer and use it in GitHub Desktop.
Save wombleton/5793520 to your computer and use it in GitHub Desktop.
Node & command line differ in hash they return ... what am I doing wrong?
// \n at the end!
console.log(require('crypto').createHash('sha1').update('blob 14\0Hello, World!\n').digest('hex'));
$> 8ab686eafeb1f44702738c8b0f24f2567c36da6d
echo -e 'blob 14\0Hello, World!' | shasum -a 1
$> 8ab686eafeb1f44702738c8b0f24f2567c36da6d
@rcoup
Copy link

rcoup commented Jun 16, 2013

or echo -ne ...

@redspider
Copy link

Yeah, as rcoup said:

$ echo -ne 'blob 14\0Hello, World!\n' | shasum -a 1
8ab686eafeb1f44702738c8b0f24f2567c36da6d  -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment