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

hashblot

v0.4.5

Published

Functions for hash visualization.

Downloads

66

Readme

hashblot

Expressive hash visualization - http://hashblot.com

What it is

Hashblot, at its most general level, is an algorithm for visualizing hash functions, by interpreting a sequence of bytes as a series of curves.

This repository contains a JavaScript library for converting byte sequences to paths, and an HTML file that takes that output for the SHA-1 hash of a string and displays the resulting image. See the "Methods" section for the exact functionality it provides.

Installation

For Node.js/browserify:

npm install --save hashblot

For Bower:

bower install hashblot

hashblot.js will assign to exports.module if present, and window.hashblot if not, allowing it to be required as a Node/browserify module or included as a <script> source.

Methods

hashblot.pd.q

Takes an array of coordinates with a length divisible by 4 and converts it to an SVG Path Description string, like so:

  1. Prefix the entire string with 'M' + the last two numbers, denoting that the 'pen' should be moved to the last position in the shape before drawing the curves, so it will finish as a closed path where it started.
  2. Append "Q", followed by all the passed-in coordinates separated by commas, to denote a series of absolute-positioned quadratic Bézier curves, with each even pair of numbers as the X and Y coordinates of the control point, and each odd pair of numbers as the X and Y coordinates of the end point.

This function is meant to be used with an array of bytes returned from a hash function. For scenarios where you only have a hexadecimal string, you can use hashblot.hexBytes to convert a hexadecimal string to an array of bytes.

hashblot.path2d.q

Takes an array of coordinates with a length divisible by 4 and an optional object implementing the CanvasPathMethods moveTo and quadraticCurveTo.

This function applies moveTo and quadraticCurveTo operations for the given hash (as described in hashblot.pd.q) to the given object. If no object is given, this function will create a new Path2D() and return that.

hashblot.sha1qpd, hashblot.sha1qpath2d

These are versions of hashblot.pd.q and hashblot.path2d.q (respectively) that take a string, which is then converted to its SHA-1 hash and used with the corresponding function.

When module is defined, this function will require and use the crypto module to produce the SHA-1 hash.

Otherwise, it will use whatever "sha1" function is bound (see hashblot.sha1 below).

hashblot.bindSha1

The SHA-1 function for hashblot.sha1qpd and hashblot.sha1qpath2d is bound to whatever value of hashblot.sha1 is defined when one of these functions is first called.

It can be bound sooner by calling hashblot.bindSha1, with an optional argument containing the SHA-1 function to use.

In browser environments where there are multiple potential SHA-1 implementations available, you can use any_sha1 to automatically define the appropriate function to use:

hashblot.bindSha1(any_sha1.from(any_sha1.utf8.bytes));

You can also copy the appropriate function for your specific library (as this module's index.html does, for Rusha).

Usage

See index.html for an example of using hashblot.js to generate an image.

For things you can use hashblot images to accomplish, see the About page.

License

The underlying methods of hashblot are released in the public domain.

The specific code of this implementation (hashblot.js and index.html) is released into the public domain under the terms of the Unlicense:

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/