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

niceware-ts

v0.0.5

Published

Niceware-TS is a TypeScript implementation of Niceware, a method for generating or converting random bytes into English language passphrases.

Downloads

158

Readme

Niceware-TS

Niceware-TS is a TypeScript implementation of Niceware, a method for generating or converting random bytes into English language passphrases. This library provides functions for generating random passphrases with a specified number of bytes of entropy, as well as converting passphrases to and from byte arrays.

Each word in the passphrase provides 16 bits of entropy, so a secure passphrase should consist of at least 3 words. With a wordlist containing 2^16 (65,536) words, Niceware is suitable for converting cryptographic keys. For example, a key with 128 bits of entropy is equivalent to an 8 word passphrase.

Niceware can be used for a variety of purposes, including generating secure and easy-to-remember passphrases and displaying cryptographic key material in a user-friendly way. A passphrase consisting of 3-5 Niceware words provides 64 bits of randomness, making it a strong password for most online services. Additionally, an 8-word Niceware phrase can be used to reconstruct an entire public/private key pair for cryptographic purposes, such as generating a 256-bit ECC key (equivalent to a 3072-bit RSA key).

Web Demo: https://diracdeltas.github.io/niceware/

Features

  • Generate random passphrases with a specified number of bytes of entropy
  • Convert passphrases to and from byte arrays
  • TypeScript implementation for type safety and ease of use
  • Small and lightweight library with no external dependencies

Improvements

  • Decode passphrases as an Array or words, or a space-delimited string
  • encode/decode odd length Uint8Arrays, padding the output
  • Exports ESM, CommonJS, and TypeScript declaration files
  • Deno compatible
  • New runtime safety checks with improved error messaging
  • New wordlist sanity tests
  • Benchmark tests

Usage

To use Niceware-TS in your TypeScript/ESM/CommonJS project, simply install it from npm:

npm install niceware-ts

Then, import the functions you need from the module:

import { bytesToPassphrase, generatePassphrase, passphraseToBytes } from 'niceware-ts';

// Generate a passphrase with 16 bytes (128 bits) of entropy
const passphrase = generatePassphrase(16);

// Convert the passphrase to a byte array
const bytes = passphraseToBytes(passphrase);

console.log(passphrase.join(' ')); // Output: "deadpanned steamily penuriously geometry elusion trainload camelback inexcusable"
console.log(bytes); // Uint8Array(16) [ 50, 222, 213,  47, 158, 168,  89,  37,  67, 191, 229, 223,  27, 197, 109, 85 ]
console.log(bytesToPassphrase(bytes).join(' ')); // Output: "deadpanned steamily penuriously geometry elusion trainload camelback inexcusable"

License

Niceware-TS is licensed under the MIT License. See LICENSE for more information.

Credits

Many thanks to Yan for creating Niceware.