npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-sha1

v1.0.1

Published

Exports a SHA1 function that uses node's crpyto module under the hood

Downloads

62,871

Readme

node-sha1 Build Status

Provides you with a convenient sha1 function that uses Node's crypto module under the hood.

Install

npm install node-sha1 --save

Usage

var sha1 = require('node-sha1');
sha1('Hello World!'); # 2ef7bde608ce5404e97d5f042f95f89f1c232871

API

sha1(what, callback)

what

Can be a string, buffer, or even a stream (stream requires a callback).

If what is a string, or a buffer the hash will be returned, if a callback is registered it will also be called with the resulting hash.

If what is a stream, it will throw if a callback is not registered. Otherwise it will call the callback with the resulting hash.

callback(err, hash)

err any errors that occurred, or undefined if no errors occurred. hash is the resulting hash. If a callback is registered it will be called with the resulting hash regardless if a stream, string, or buffer is used.

Examples

Use with strings

var sha1 = require('node-sha1');
sha1('Hello World!'); # 2ef7bde608ce5404e97d5f042f95f89f1c232871

Use with buffers

var sha1 = require('node-sha1');
var buffer = new Buffer('Hello World!');
sha1(buffer); # 2ef7bde608ce5404e97d5f042f95f89f1c232871

Use with streams

var sha1 = require('node-sha1');

util.inherits(FakeStream, stream.Readable);

function FakeStream() {
  this._finished = false;
  stream.Readable.call(this);
}

FakeStream.prototype._read = function() {
  if (this._finished) {
    this.push(null);
    return;
  }
  this._finished = true;
  this.push('Hello World!');
};

var fakeStream = new FakeStream();
sha1(fakeStream, function(err, hash) {
  # hash = 2ef7bde608ce5404e97d5f042f95f89f1c232871
})