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

sign-prng

v1.0.1

Published

Create random hex signatures and turn them into consistent, reproducible random number sequences. Same signature always produces the same numbers - perfect for deterministic testing and shareable random states

Readme

sign-prng

🔧 A module for generating and validating hexadecimal signatures, creating pseudo-random numbers, and computing hashes based on deterministic signatures.

Installation

npm install sign-prng

Usage

import sign from 'sign-prng'

API

sign.generate(bytesLength?: number): string

Generates a random signature as a hexadecimal string.

Parameters:

  • bytesLength - Length in bytes (default: 16)

Returns: Hexadecimal string (32 chars for 16 bytes)

Example:

const signature = sign.generate()
// => "a1ace80f9fabed1bc4b2d28bd5081afc"

const longSignature = sign.generate(32)
// => "a1b2c3...64 chars"

sign.check(signature: string): boolean

Validates if a string is a valid hexadecimal signature.

Parameters:

  • signature - String to validate

Returns: true if valid, false otherwise

Example:

sign.check('a1ace80f9fabed1bc4b2d28bd5081afc') // => true
sign.check('invalid') // => false

sign.getMatRandomFn(signature: string): () => number

Returns a deterministic pseudo-random number generator (0-1) based on signature.

Parameters:

  • signature - Source signature for seeding

Returns: Function that returns numbers between 0 and 1

Example:

const random = sign.getMatRandomFn('a1ace80f9fabed1bc4b2d28bd5081afc')

random() // => 0.7336...
random() // => 0.5182...

// Same signature produces same sequence
const random2 = sign.getMatRandomFn('a1ace80f9fabed1bc4b2d28bd5081afc')
random2() // => 0.7336... (same as first call)

sign.getIntFn(signature: string, max?: number): () => number

Returns a deterministic integer generator (0 to max) based on signature.

Parameters:

  • signature - Source signature for seeding
  • max - Maximum value (default: 1)

Returns: Function that returns integers from 0 to max

Example:

const getInt = sign.getIntFn('a1ace80f9fabed1bc4b2d28bd5081afc', 100)

getInt() // => 42
getInt() // => 71
getInt() // => 61

sign.getMod(signature: string, max: number): number

Calculates modulo of signature by max value.

Parameters:

  • signature - Hexadecimal signature
  • max - Maximum value for modulo operation

Returns: Integer from 0 to max

Example:

sign.getMod('a1ace80f9fabed1bc4b2d28bd5081afc', 100)
// => 42 (always the same for this signature)

sign.sha(str: string): string

Computes a simple hash of a string.

Parameters:

  • str - Input string to hash

Returns: Hexadecimal hash string

Example:

sign.sha('hello') // => "5d41402abc..."
sign.sha('world') // => "7c211433f0..."

Use Cases

  • Deterministic randomness: Use signatures as seeds for reproducible random sequences
  • ID generation: Create random hex identifiers
  • Reproducible states: Generate consistent states from seed values (games, simulations, testing)

License

ISC