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

@lecturedoc2/libcrypto

v1.1.0

Published

Simple library which provides basic crypto functionality across web and node projects.

Readme

ld-libcrypto

Provides basic, but secure functionality to encrypt and decrypt strings. The library can be used in Node as well as web projects and has no runtime dependencies.

Encryption is AES-GCM with a 256 bit key derived from the password using PBKDF2 (SHA-256), with a random 32 byte salt and a random 12 byte IV per message.

Installation

npm install @lecturedoc2/libcrypto

Usage

import { encryptAESGCMPBKDF, decryptAESGCMPBKDF } from "@lecturedoc2/libcrypto";

const encrypted = await encryptAESGCMPBKDF(
  "secret message",
  "password",
  250000,
);
// => "MjUwMDAw:<salt>:<iv>:<ciphertext>"  (base64 fields, ":" separated)

const plaintext = await decryptAESGCMPBKDF(encrypted, "password");
// => "secret message"

API

encryptAESGCMPBKDF(plaintext, password, iterations)Promise<string>

Returns a self-describing string of four base64 fields joined by : — the PBKDF2 iteration count, the salt, the IV, and the ciphertext (which includes the GCM authentication tag). Throws if the password is not a non-empty string.

decryptAESGCMPBKDF(encrypted, password)Promise<string>

Takes the string produced by encryptAESGCMPBKDF. The iteration count, salt and IV are read back out of it, so they do not need to be supplied. Rejects if the password is wrong or the message has been tampered with.

Choose iterations to suit the threat model — OWASP currently suggests 600,000 for PBKDF2-HMAC-SHA256. Low values are fast but weaken the protection of the derived key.

Requirements

Node 24+, or any browser with the Web Crypto API. In browsers, crypto.subtle is only available in secure contexts (HTTPS or localhost).

Development

pnpm install
pnpm test        # runs the Jest suite against src/
pnpm build       # writes dist/libcrypto.min.js + sourcemap
pnpm test:dist   # smoke-tests the built bundle

The published package exposes the minified bundle by default. The unminified source is also shipped and can be imported explicitly:

import { encryptAESGCMPBKDF } from "@lecturedoc2/libcrypto/src/libcrypto.js";