to-sha1

1.2.1 • Public • Published

Build Status npm version

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.

Readme

Keywords

Package Sidebar

Install

npm i to-sha1

Weekly Downloads

12

Version

1.2.1

License

ISC

Unpacked Size

5.53 kB

Total Files

7

Last publish

Collaborators

  • c33k