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

@jedisct1/charm

v2.0.0

Published

Charm port to JavaScript

Readme

charm.js

A tiny, self-contained cryptography library, implementing authenticated encryption and keyed hashing.

Any number of hashing and authenticated encryption operations can be freely chained using a single rolling state. In this mode, each authentication tag authenticates the whole transcript since the beginning of the session.

This is a port to JavaScript (TypeScript). It is fully compatible with the C and Zig versions.

Features

  • Authenticated encryption with 128-bit security
  • Keyed hashing
  • No practical limits on message size and length
  • Works in both Node.js and Bun environments
  • Supports both ESM and CommonJS module systems
  • Full TypeScript support with type definitions
  • Zero dependencies
  • Comprehensive test coverage

Installation

npm install @jedisct1/charm

Usage

ESM

import { Charm } from "@jedisct1/charm";

// Create a key and nonce
const key = new Uint8Array(Charm.key_length).fill(1);
const nonce = new Uint8Array(Charm.nonce_length).fill(2);

// Create a message
const message = new TextEncoder().encode('Hello from Charm!');

// Initialize the state
const charm = new Charm(key, nonce);

// Encrypt
const tag = charm.encrypt(message);

// Decrypt
const charm2 = new Charm(key, nonce);
charm2.decrypt(message, tag);

// Hash
const hash = charm.hash(message);

CommonJS

const { Charm } = require("@jedisct1/charm");

// Create a key and nonce
const key = new Uint8Array(Charm.key_length).fill(1);
const nonce = new Uint8Array(Charm.nonce_length).fill(2);

// Create a message
const message = new TextEncoder().encode('Hello from Charm!');

// Initialize the state
const charm = new Charm(key, nonce);

// Encrypt
const tag = charm.encrypt(message);

// Decrypt
const charm2 = new Charm(key, nonce);
charm2.decrypt(message, tag);

// Hash
const hash = charm.hash(message);

API

Constructor

new Charm(key: Uint8Array, nonce?: Uint8Array)
  • key: A Uint8Array of length Charm.key_length (32 bytes)
  • nonce: An optional Uint8Array of length Charm.nonce_length (16 bytes)

Static Properties

  • Charm.key_length: 32 (bytes)
  • Charm.nonce_length: 16 (bytes)
  • Charm.tag_length: 16 (bytes)
  • Charm.hash_length: 32 (bytes)

Methods

encrypt(msg: Uint8Array): Uint8Array

Encrypts a message in-place and returns the authentication tag.

decrypt(msg: Uint8Array, expected_tag: Uint8Array): void

Decrypts a message in-place and verifies the authentication tag. Throws an error if verification fails.

hash(msg: Uint8Array): Uint8Array

Computes a keyed hash of the message.

Development

Building

npm run build

This will build both ESM and CommonJS versions of the library.

Testing

npm test

Linting

npm run lint

Security

This implementation provides 128-bit security and has no practical limits on the size and length of messages.

Other implementations

  • charm original implementation in C
  • zig-charm an implementation of Charm in the Zig language

License

MIT