hash-dir-contents

A simple function for computing the hash of the contents of an entire directory.

Usage no npm install needed!

<script type="module">
  import hashDirContents from 'https://cdn.skypack.dev/hash-dir-contents';
</script>

README

hash-dir-contents

A simple function for computing the hash of the contents of an entire directory.

Build Status Coverage Status NPM version Dependency Status

NPM

Installation

npm install hash-dir-contents

Usage

This module exports a function that has the following signature:

function([options], callback)

where options is an object that can contain the following properties:

  • directory - (optional) The directory to hash the contents of. Defaults to the current working directory.
  • algorithm - (optional) The algorithm to use to hash the content, "sha1" or "md5". Defaults to "sha1".

and callback is a function that will be passed an error object as the first parameter and the hash as the second parameter.

Examples

var hasher = require('hash-dir-contents');

hasher({
    directory: '/home/me/stuff',
    algorithm: 'md5'
}, function(error, hash) {
    console.log(hash); // example: '843d5af0230cb6ddcd767e9d92f7e152'
});

Bitdeli Badge