sha512sum
v1.0.9
Published
The same behaviour as linux command with directories support.
Downloads
122
Readme
sha512sum
The same behaviour as linux command with directories support. https://linux.die.net/man/1/sha512sum
Works on Linux and Windows.
Install
$ npm install --save sha512sum
Usage
For a file
const sha512sum = require('sha512sum');
// 992 ... 80a /path/to/file
sha512sum.fromFile('/path/to/file', options, function(err, hash) {
if (err) throw err
console.log(hash)
});
console.log(sha512sum.fromFileSync('/path/to/file', options))
Similar to linux command:
$ sha512sum /path/to/file
For a directory
const sha512sum = require('sha512sum');
// 992 ... 80a /path/to/dir/h.txt
// erf ... e3f /path/to/dir/b/e.doc
// cd5 ... r9g /path/to/dir/b/l.png
// b2r ... v2f /path/to/dir/c/l.csv
// adr ... 9t6 /path/to/dir/d/o.world
sha512sum.fromDirectory('/path/to/dir', options, function(err, hash) {
if (err) throw err
console.log(hash)
});
console.log(sha512sum.fromDirectorySync('/path/to/dir', options))
Similar to linux command:
$ find files -type f -printf "%d%p\n" | sort -n | cut -c 2- | xargs sha512sum
Options
- cwd: current work directory
- sep: separator between hash and filename, default value is double-space