to-sha1
v1.2.1
Published
Receives input (stream or filename) and outputs SHA1 of the content.
Downloads
13
Readme
to-sha1
Convert string or file contents to SHA1.
usage
As Command Line
First, install to-sha1 globally:
npm i -g to-sha1
You can then use it with pipes:
echo -n "some string I want to hash" | to-sha1
Or passing arguments.
[-s | --string]
Receives string as argument and return SHA-1:
$ to-sha1 -s "Random text..."
[-f | --filename]
Receives the filepath as argument and return SHA-1 of it's content:
$ to-sha1 -f <filepath>
[-h | --help]
Displays accepted arguments.
As Regular Node Module
const { toSHA1, sha1 } = require('to-sha1')
//Using SHA1 function directly
//... get file content or text from somewhere ...
var hashedData = sha1(data);
//Using toSHA1 to hash a specific file
toSHA1('filepath', (err, hashedContent) => {
if(err) console.log(`Something went wrong!`, err)
console.log(hashedContent) //or do something else...
})
methods
const { toSHA1, sha1 } = require('to-sha1')
sha1(string)
Returns the hash of a given string.
toSHA1(filename, cb)
Hash a file asynchronously. If there is any error during processing (eg. file doesn't exist, invalid permissions or it is a directory) cb function will be called with the error as first argument.