hash_file

0.1.1 • Public • Published

build status

Hash File

A simple utility for getting the hash of a file or Buffer.

Supported Hash Types

  • MD4
  • MD5
  • SHA1
  • SHA256

Installation

npm install hash_file

Usage

var hash_file = require('hash_file')
 
// get md5
hash_file('./README.md', 'md5', function(err, hash) {
  console.log('md5:', hash)
})
 
// get sha1 
hash_file('./README.md', 'sha1', function(err, hash) {
  console.log('sha1:', hash)
})
 
// get sha256 
hash_file('./README.md', 'sha256', function(err, hash) {
  console.log('sha256:', hash)
})
 
// on a Buffer
var buf = crypto.randomBytes(1024)
 
hash_file(buf, 'md5', function (err, hash) {
  console.log('md5:', hash)
})
 
// or simply:
console.log('md5:', hash_file(buf, 'md5'))

Running the tests

> npm install
> npm test

Credits

Code originally adapted from Gregor Schwab greg@synaptic-labs.net (dotmaster)

License

(The MIT License)

Copyright (c) 2011 Gregor Schwab <dev@synaptic-labs.net>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Readme

Keywords

none

Package Sidebar

Install

npm i hash_file

Weekly Downloads

110

Version

0.1.1

License

none

Last publish

Collaborators

  • timoxley