1.2.1 • Published 5 years ago

to-sha1 v1.2.1

Weekly downloads
11
License
ISC
Repository
github
Last release
5 years ago

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.

1.2.1

5 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago