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

@bturkis/keygen

v1.0.0

Published

Cryptographically secure key generators — hex keys, UUIDs, passwords, random strings, and text-to-key hashing. Uses Web Crypto API.

Readme

@bturkis/keygen

Cryptographically secure key generators for Node.js, Deno, and browsers.
All generators use Web Crypto API (crypto.getRandomValues) — no Math.random().

npm version License: MIT

🌐 Website: keygen.neisterse.com

Install

npm install @bturkis/keygen
# or
pnpm add @bturkis/keygen
# or
yarn add @bturkis/keygen

Quick Start

import {
  generateHexKey,
  generateUUID,
  generatePassword,
  generateSecretKey,
  generateRandomString,
  textToKey,
} from "@bturkis/keygen";

// Hex key (256-bit)
const hexKey = generateHexKey();
// => ["a1b2c3d4e5f6..."]

// UUID v4
const uuid = generateUUID();
// => ["550e8400-e29b-41d4-a716-446655440000"]

// Secure password
const password = generatePassword({ length: 16 });
// => ["xK9@mP2#qR5&wT8!"]

// Secret key (mixed chars)
const secret = generateSecretKey({ length: 64 });
// => ["x!K9@mP2#qR5&wT8..."]

// Random alphanumeric string
const token = generateRandomString({ length: 24 });
// => ["Abc123Xyz456DefGHij789Klm"]

// Text to SHA-256 hash
const hash = await textToKey("hello world");
// => "b94d27b9934d3e08..."

API Reference

generateHexKey(options?)

Generate cryptographically secure hex keys.

| Option | Type | Default | Description | | ------------------- | --------- | ------- | -------------------------- | | bytes | number | 32 | Number of random bytes | | count | number | 1 | Number of keys to generate | | prefix | string | "" | Prepend to each key | | suffix | string | "" | Append to each key | | separator | string | "" | Between hex segments | | separatorInterval | number | 0 | Chars between separators | | uppercase | boolean | false | Uppercase hex output |

// API key with prefix
generateHexKey({ bytes: 32, prefix: "sk_live_" });

// MAC address style
generateHexKey({
  bytes: 6,
  separator: ":",
  separatorInterval: 2,
  uppercase: true,
});
// => ["A1:B2:C3:D4:E5:F6"]

generateUUID(options?)

Generate RFC 4122 compliant UUID v4 identifiers.

| Option | Type | Default | Description | | ------- | -------- | ------- | --------------- | | count | number | 1 | Number of UUIDs |

generatePassword(options?)

Generate secure passwords. Quotes (' and ") excluded by default for shell/SQL safety.

| Option | Type | Default | Description | | --------------- | --------- | ------- | ------------------------ | | length | number | 16 | Password length | | count | number | 1 | Number of passwords | | uppercase | boolean | true | Include A-Z | | lowercase | boolean | true | Include a-z | | numbers | boolean | true | Include 0-9 | | symbols | boolean | true | Include special chars | | customSymbols | string | — | Override default symbols |

// Simple password
generatePassword({ length: 8, symbols: false });

// Custom symbols only
generatePassword({ customSymbols: "!@#$", length: 20 });

generateSecretKey(options?)

High-entropy keys with letters, digits, and special characters.

| Option | Type | Default | Description | | -------- | -------- | ------- | -------------- | | length | number | 32 | Key length | | count | number | 1 | Number of keys |

generateRandomString(options?)

Alphanumeric strings (A-Z, a-z, 0-9). Safe for URLs, filenames, and databases.

| Option | Type | Default | Description | | -------- | -------- | ------- | ----------------- | | length | number | 16 | String length | | count | number | 1 | Number of strings |

textToKey(text, options?)

Convert text to a deterministic hash. Returns a Promise<string>.

| Option | Type | Default | Description | | ----------- | -------- | ----------- | ---------------------------------------- | | algorithm | string | "SHA-256" | SHA-1, SHA-256, SHA-384, SHA-512 |

calculateEntropy(params)

Calculate entropy information for a key configuration.

import { calculateEntropy } from "@bturkis/keygen";

calculateEntropy({ bytes: 32 });
// => { bits: 256, strength: "very-strong", label: "Very Strong - Maximum security" }

calculateEntropy({ charPool: 92, length: 16 });
// => { bits: 104, strength: "fair", label: "Fair - Acceptable for basic security" }

Security

  • ✅ Uses crypto.getRandomValues() (Web Crypto API)
  • ✅ No Math.random() — cryptographically secure
  • ✅ Works in Node.js 18+, Deno, and modern browsers
  • ✅ Zero runtime dependencies (except uuid for UUID v4)
  • ✅ Tree-shakeable ESM + CJS builds

License

MIT © bturkis