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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kudos-protocol/subject-hash

v1.0.3

Published

A library for generating a Subject-Hash from a subject

Readme

@kudos-protocol/subject-hash

This library converts a subject identifier (for example email:[email protected]) into a stable 128-bit identifier suitable for use in databases, ledgers, routing systems, etc.

It is the reference implementation of the Subject Hash used across the Kudos Protocol ecosystem.


Install

npm install @kudos-protocol/subject-hash

Overview

A Subject in the Kudos Protocol is a canonical identifier for an entity:

type:opaque_id

Examples:

email:[email protected]
github:octocat
pool:https://kps.example.com/pool/abc
subject-hash:tmwIJmeStJDSo9giG47rcw

Subject hashes provide a compact, fixed-length identifier derived from the subject string.


Algorithm

The Subject Hash algorithm is defined as:

SubjectHash(subject) :=
    base64url( SHA256(trim(subject))[0..15] )

Steps:

  1. Convert input to string and trim whitespace
  2. Compute SHA-256 of the subject
  3. Take the first 16 bytes (128 bits) of the digest
  4. Encode using Base64 URL-safe encoding (RFC 4648, no padding)

This produces a 22-character identifier.

Example:

email:[email protected]
↓
tmwIJmeStJDSo9giG47rcw

Usage

Default (base64url)

import { getSubjectHash } from "@kudos-protocol/subject-hash"

const hash = getSubjectHash("email:[email protected]")

console.log(hash)
// tmwIJmeStJDSo9giG47rcw

Hex output

const hash = getSubjectHash("email:[email protected]", "hex")

console.log(hash)
// b66c08266792b490d2a3d8221b8eeb73

BigInt output

const hash = getSubjectHash("email:[email protected]", "bigint")

console.log(hash)
// 242480428595577766886520952605903874931n

Output formats


Format Length Example


base64url 22 chars tmwIJmeStJDSo9giG47rcw

hex 32 chars b66c08266792b490d2a3d8221b8eeb73

bigint 128-bit integer 242480428595577766886520952605903874931n


CLI

The package includes a CLI for quick lookups:

subject-hash email:[email protected]
# tmwIJmeStJDSo9giG47rcw

subject-hash --hex email:[email protected]
# b66c08266792b490d2a3d8221b8eeb73

subject-hash --bigint email:[email protected]
# 242480428595577766886520952605903874931

subject-hash --json email:[email protected]
# {"subject":"email:[email protected]","format":"base64url","hash":"tmwIJmeStJDSo9giG47rcw"}

Reads from stdin when piped:

echo email:[email protected] | subject-hash
# tmwIJmeStJDSo9giG47rcw

Or run via npx without installing:

npx @kudos-protocol/subject-hash email:[email protected]

Normalization

The library performs minimal normalization:

subject = String(subject).trim()

No other canonicalization is applied.

For example:

email:[email protected]
email:[email protected]

produce different hashes.

Systems that require canonicalization (for example email case normalization) should perform it before hashing.


See Also

License

MIT