mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
isaacs
f645c40fcd
|
11 years ago | |
---|---|---|
.. | ||
node_modules/readable-stream | 11 years ago | |
.npmignore | 11 years ago | |
LICENSE | 11 years ago | |
README.md | 11 years ago | |
index.js | 11 years ago | |
package.json | 11 years ago |
README.md
sha
Check and get file hashes (using any algorithm)
Installation
$ npm install sha
API
check(fileName, expected, [options,] cb) / checkSync(filename, expected, [options])
Asynchronously check that fileName
has a "hash" of expected
. The callback will be called with either null
or an error (indicating that they did not match).
Options:
- algorithm: defaults to
sha1
and can be any of the algorithms supported bycrypto.createHash
get(fileName, [options,] cb) / getSync(filename, [options])
Asynchronously get the "hash" of fileName
. The callback will be called with an optional error
object and the (lower cased) hex digest of the hash.
Options:
- algorithm: defaults to
sha1
and can be any of the algorithms supported bycrypto.createHash
stream(expected, [options])
Check the hash of a stream without ever buffering it. This is a pass through stream so you can do things like:
fs.createReadStream('src')
.pipe(sha.stream('expected'))
.pipe(fs.createWriteStream('dest'))
dest
will be a complete copy of src
and an error will be emitted if the hash did not match 'expected'
.
Options:
- algorithm: defaults to
sha1
and can be any of the algorithms supported bycrypto.createHash
License
You may use this software under the BSD or MIT. Take your pick. If you want me to release it under another license, open a pull request.