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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@chelonia/crypto

v1.0.1

Published

Contains various utilities for performing cryptographic operations.

Readme

Chelonia Crypto Library

A cryptographic library providing secure key management, encryption, and signature operations for Node.js and browser applications.

Installation

npm install @chelonia/crypto

Features

  • Key generation and management for various cryptographic algorithms
  • Password-based key derivation
  • Message signing and verification
  • Symmetric and asymmetric encryption
  • Support for ed25519, curve25519, and XSalsa20-Poly1305

Supported Algorithms

  • edwards25519sha512batch - Ed25519 for signatures
  • curve25519xsalsa20poly1305 - Curve25519 for asymmetric encryption
  • xsalsa20poly1305 - XSalsa20-Poly1305 for symmetric encryption

Usage Examples

Key Generation

import { keygen, EDWARDS25519SHA512BATCH, CURVE25519XSALSA20POLY1305, XSALSA20POLY1305 } from '@chelonia/crypto';

// Generate an Ed25519 key pair for signing
const signingKey = keygen(EDWARDS25519SHA512BATCH);

// Generate a Curve25519 key pair for asymmetric encryption
const encryptionKey = keygen(CURVE25519XSALSA20POLY1305);

// Generate a symmetric encryption key
const symmetricKey = keygen(XSALSA20POLY1305);

Serializing and Deserializing Keys

import { serializeKey, deserializeKey } from '@chelonia/crypto';

// Serialize a key (with secret key)
const serializedKey = serializeKey(key, true);

// Serialize a key (public key only)
const serializedPublicKey = serializeKey(key, false);

// Deserialize a key
const deserializedKey = deserializeKey(serializedKey);

Password-Based Key Derivation

import { deriveKeyFromPassword, generateSalt, EDWARDS25519SHA512BATCH } from '@chelonia/crypto';

// Generate a random salt
const salt = generateSalt();

// Derive a key from a password and salt
const key = await deriveKeyFromPassword(EDWARDS25519SHA512BATCH, 'password123', salt);

Signing and Verifying

import { sign, verifySignature, EDWARDS25519SHA512BATCH, keygen } from '@chelonia/crypto';

const key = keygen(EDWARDS25519SHA512BATCH);
const data = 'message to sign';

// Sign a message
const signature = sign(key, data);

// Verify a signature
try {
  verifySignature(key, data, signature);
  console.log('Signature is valid');
} catch (error) {
  console.error('Signature verification failed:', error);
}

Encryption and Decryption

import { encrypt, decrypt, keygen, CURVE25519XSALSA20POLY1305, XSALSA20POLY1305 } from '@chelonia/crypto';

// Asymmetric encryption
const asymmetricKey = keygen(CURVE25519XSALSA20POLY1305);
const encryptedData = encrypt(asymmetricKey, 'secret message');
const decryptedData = decrypt(asymmetricKey, encryptedData);

// Symmetric encryption
const symmetricKey = keygen(XSALSA20POLY1305);
const encryptedWithSymmetric = encrypt(symmetricKey, 'secret message');
const decryptedWithSymmetric = decrypt(symmetricKey, encryptedWithSymmetric);

// With additional data (AD)
const encryptedWithAD = encrypt(symmetricKey, 'secret message', 'additional data');
const decryptedWithAD = decrypt(symmetricKey, encryptedWithAD, 'additional data');

API Reference

Key Management

  • keygen(type: string): Key - Generate a key pair of the specified type
  • serializeKey(key: Key, saveSecretKey: boolean): string - Serialize a key to JSON
  • deserializeKey(data: string): Key - Deserialize a key from JSON
  • keygenOfSameType(key: Key | string): Key - Generate a new key of the same type
  • keyId(key: Key | string): string - Generate a unique ID for a key
  • generateSalt(): string - Generate a random salt
  • deriveKeyFromPassword(type: string, password: string, salt: string): Promise<Key> - Derive a key from a password

Cryptographic Operations

  • sign(key: Key | string, data: string): string - Sign data with a key
  • verifySignature(key: Key | string, data: string, signature: string): void - Verify a signature
  • encrypt(key: Key | string, data: string, ad?: string): string - Encrypt data with a key
  • decrypt(key: Key | string, data: string, ad?: string): string - Decrypt data with a key

License

AGPL 3.0.