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

siphash

v1.1.0

Published

SipHash-2-4 fast short-input pseudo-random function

Downloads

133,163

Readme

siphash.js

A pure Javascript implementation of SipHash-2-4

SipHash is a family of pseudorandom functions optimized for short inputs. Target applications include network traffic authentication and hash-table lookups protected against hash-flooding denial-of-service attacks. SipHash has well-defined security goals and competitive performance.

This package also includes implementations of SipHash-1-3, SipHash128, and SipHash128-1-3.

Installation

Server-side installation (io.js/nodejs):

$ npm install siphash

Browser-side/single-line minified version: use lib/siphash.js.min. or use Bower:

$ bower install siphash

Usage

var siphash = require("siphash"),
    key = siphash.string16_to_key("This is the key!"),
    message = "Short test message",
    hash_hex = siphash.hash_hex(key, message);

A key is an array of 4 integers, and each of them will be clamped to 32 bits in order to build a 128-bit key. For a random key, just generate 4 random integers instead of calling string16_to_key().

var siphash = require("siphash"),
    key = [ 0xdeadbeef, 0xcafebabe, 0x8badf00d, 0x1badb002 ],
    message = "Short test message",
    hash_hex = siphash.hash_hex(key, message);

The 64-bit hash can also be obtained as two 32-bit values with hash(key, message):

var siphash = require("siphash"),
    key = [ 0xdeadbeef, 0xcafebabe, 0x8badf00d, 0x1badb002 ],
    message = "Short test message",
    hash = siphash.hash(key, message),
    hash_msb = hash.h,
    hash_lsb = hash.l;

A 53-bit unsigned integer can be obtained with hash_uint(key, message):

var siphash = require("siphash"),
    key = siphash.string16_to_key("0123456789ABCDEF"),
    message = "Short test message",
    index = siphash.hash_uint(key, message);

SipHash-1-3

SipHash-1-3 is a faster variant of SipHash-2-4 with fewer rounds, which is still believed to be secure enough for typical uses. This variant is available here: siphash13.js

SipHash-double

Although not part of the module, an implementation of SipHash with 128-bit output is also available: siphash-double.js

SipHash-1-3 with a 128-bit output is also part of the package: siphash13-double.js