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

@pickl/db-ids

v0.0.9

Published

A library to generate encrypted database IDs. It uses a WASM-based implementation of AES for insanely fast performance.

Readme

node-db-ids

A library to generate encrypted database IDs. It uses a WASM-based implementation of AES for insanely fast performance.

The primary use case for this library is to obfuscate internal incrementing database IDs when exposing them to external systems or customers. By encrypting your IDs, you can maintain database efficiency (keeping IDs as int or bigint) while reducing the risk of enumeration attacks.

Also the IDs generated are self-describing and shorter than UUIDs.

Usage

Creating a Provider

Create a DBIdProvider instance with a secret key:

const { DBIdProvider } = require('node-db-id');

// Create a provider with the secret key "aaaaaaa"
const provider = new DBIdProvider("aaaaaaa");

Encrypting an ID

Encrypt up to a 96 bit ID using the secret key and a scope.

const encrypted = provider.fromParts({ id: 1n, scope: "tbl" });
console.log("Encrypted:", encrypted);

Decrypting an ID

Decode a serialized ID using the secret key. This will return an object containing the scope and the original ID.

const decrypted = provider.fromString(encrypted.payload);
console.log("Decrypted:", decrypted);

Benchmark

A single-core benchmark was run using Node.js v23.4.0 on a Ryzen 9 5900X:

const { DBIdProvider } = require('node-db-id');
(function () {
  const a = new DBIdProvider("aaaaaaa");
  const encrypted = a.fromParts({ id: 1n, scope: "tbl" });
  console.log("Encrypted:", encrypted);
  const decrypted = a.fromString(encrypted.payload);
  console.log("Decrypted:", decrypted);

  let start = performance.now();
  for (let i = 0; i < 10 ** 7; i++) {
    a.fromParts({ id: 1n, scope: "tbl" });
  }
  console.log("Encrypt (ops/s):", 10 ** 10 / (performance.now() - start));

  start = performance.now();
  for (let i = 0; i < 10 ** 7; i++) {
    a.fromString(encrypted.payload);
  }
  console.log("Decrypt (ops/s):", 10 ** 10 / (performance.now() - start));
})();

Results

Encrypted: DBId {
  scope: 'tbl',
  id: 1n,
  payload: 'tbl_uoXRuMlMYhM2esa1eGZey'
}
Decrypted: DBId {
  scope: 'tbl',
  id: 1n,
  payload: 'tbl_uoXRuMlMYhM2esa1eGZey'
}
Encrypt (ops/s): 1394990.0318232172
Decrypt (ops/s): 1081373.6576548016

Caveats

  • Key Rotation: Since IDs need to be durable, rotating the secret keys used for encryption can be challenging, if not impossible. To mitigate this, consider using a separate secret key for each scope.
  • Security: Ensure your secret keys are stored securely and never exposed in client-side code.

License

This project is licensed under the MIT License. See the LICENSE file for details.