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

@ekaone/entropy

v0.1.1

Published

Primitive Shannon entropy measurement for strings.

Readme

@ekaone/entropy

Primitive Shannon entropy measurement for strings.

Measures randomness density — best used for generated tokens, secrets, and API keys. Not intended for judging human-chosen passwords. Refer to Shannon entropy for details.

Installation

npm install @ekaone/entropy
yarn add @ekaone/entropy
pnpm add @ekaone/entropy

Usage

Basic — pure measurement

import { calculate } from "@ekaone/entropy"

calculate("hsg3-3;gs")
// { entropy: 3.46, length: 9, unique: 8 }

With level option

calculate("hsg3-3;gs", { level: true })
// { entropy: 3.46, length: 9, unique: 8, level: "medium" }

With charset option

calculate("hsg3-3;gs", { level: true, charset: true })
// { entropy: 3.46, length: 9, unique: 8, level: "medium", charset: "mixed" }

Custom thresholds

calculate("hsg3-3;gs", {
  level: { thresholds: { high: 5.0 } }
})

Tree-shakeable primitives

import { shannonEntropy } from "@ekaone/entropy"
import { classifyLevel, DEFAULT_THRESHOLDS } from "@ekaone/entropy"
import { detectCharset } from "@ekaone/entropy"

API

calculate(input, options?)

| Field | Type | Description | |---|---|---| | entropy | number | Shannon bits per character | | length | number | String length | | unique | number | Count of distinct characters | | level | EntropyLevel | Returned when options.level is set | | charset | CharSet | Returned when options.charset is set |

Options

| Option | Type | Description | |---|---|---| | level | boolean \| { thresholds? } | Enable level classification | | charset | boolean | Enable charset detection |

Entropy levels (defaults)

| Level | Bits | Typical example | |---|---|---| | low | < 2.5 | "aaaa", "1111" | | medium | 2.5–3.5 | "hsg3-3;gs" | | high | 3.5–4.5 | random hex hashes | | critical | ≥ 4.5 | API keys, JWT secrets |

Charset detection

| Charset | Rule | |---|---| | numeric | digits only | | alpha | letters only | | hex | [0-9a-fA-F] with both digits and letters, no letters outside a-f | | alphanumeric | letters + digits, not purely hex | | mixed | contains special characters |

Note: "deadbeef" classifies as alpha (no digits). "abc123" classifies as hex (all chars within hex range). This is expected — see charset ambiguity.

Charset ambiguity

Strings using only [0-9a-fA-F] characters are inherently ambiguous. @ekaone/entropy resolves this by requiring hex strings to contain both digits and letters within the a-f range. Pure-letter strings always classify as alpha regardless of whether their characters fall within hex range.

Building on top

This package is a primitive. Higher-level opinions live in consumer packages:

import { calculate } from "@ekaone/entropy"

// your app defines "strong"
const { entropy, length } = calculate(token)
const isStrong = entropy >= 4.0 && length >= 16

// your UI defines the label
const score = Math.round((entropy / 6.55) * 100)

License

MIT © Eka Prasetia

Links