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

o2.random

v0.1.4

Published

o2.js — A utility to generate random hex strings with various cryptographical strength. — http://o2js.com/.

Downloads

4

Readme

        ___       _
  ____ |__ \     (_)____
 / __ \__/ /    / / ___/
/ /_/ / __/_   / (__  )    A Coherent Solution
\____/____(_)_/ /____/  to Your JavaScript Dilemma ;)
           /___/

o2.random (v.0.1.4)

A utility to generate random hex strings with various cryptographical strength.

o2.random uses callbacks, and does not block the program execution.

Summary

// TODO: insert the o2js.com blog post reference here.

This module tries to create secure random numbers with varying cryptographical strengths.

It tries to generate a random number, and it it fails tries two more times with a certain timeout. If it still fails the algorithm downgrades to a less secure random number generator and retries several times too.

If all entropy-based cryptographical methods fail, the generator fallbacks to a Math.random()-based algorithm; which is guaranteed to give a random number with indeterminate strength.

The cryptographical strengths of the generators are in the following order:

generateSecureRandom > generatePseudoRandom > generateRandom

Installation

$ npm install o2.random

Usage Example

// TODO: add server-side and client-side examples. // TODO: all readmes should have a similar structure.

var random = require('o2.random'),
    num1 , num2, num3;

//
// Cryptographically secure; pretty fast.
//
num1 = random.generateSecureRandom(12, function(err, data) {
    console.log('num1: "' + data + '"');
});

//
// Reasonably secure; pretty fast.
//
num2 = random.generatePseudoRandom(22, function(err, data) {
    console.log('num2: "' + data  + '"');
});

//
// The Fastest of all;
// The least secure of all;
//
// Still has enough entropy for large data;
// So it's practically suitable for most projects.
//
num3 = random.generateRandom(44, function(err, data) {
    console.log('num3: "' + data + '"');
});

Generates an output similar to this:

/usr/local/bin/node index.js
num3: "decb79ab102201a25ca38235f3d34cab9d32a81fc04198cc4dd40cafac08788affd9ec40ca8abe2f849b7f3a"
num1: "cd645968f31d22dcc6764f9f"
num2: "7c4b8e28bac17ca2f02a83bf682b1900348aa51bb61f"

Documentation

// TODO: add live url

See DOCUMENTATION.md

Contact Information