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

@tubitid/cryptbox

v1.0.1

Published

Data encrypting and signing library with small sized data outputs.

Downloads

18

Readme

cryptbox

Data encryption and signing library used by the TubitID to sign and encrypt badges. Aims to create the lowest size output with the given data and encryption/signature methods. Can encrypt(aes/3des) and box the data with a variable sized hmac signature(truncated) or a fixed size ECDSA signature.

For symmetric key signatures, HMAC-SHA512 is used. For asymmetric(prrivate/public key) signatures, ECDSA with different curve options is used. The encryption can be done by either using AES or 3DES. Libraries used are meant to be cross-platform and this package is aimed to be used on react-native, web and node platforms.

This package can be used with any kind of arbitrary data, since it works with Buffers/Uint8Arrays. For TubitID, it is used to add protection and signature capabilities to our qr code badges.

Libraries used

For signing, encryption and cross platform buffer support, below libraries are used.

Installattion

Run npm install --save @tubitid/cryptbox to install this package.

Usage

The package follows the es module exports convention.

const assert = require('assert');
const { Cryptbox, EncryptionAlgorithm, ECDSACurve } = require('@tubitid/cryptbox');
// or
// import { Cryptbox, EncryptionAlgorithm, ECDSACurve } from '@tubitid/cryptbox';

const cryptbox = Cryptbox.builder()
  // the created instance will use p192 curve with the given pub and priv keys
  // if the priv key isn't given, you can still use the cryptbox for verifying, but not for signing.
  .withECDSASignature(ECDSACurve.p192, 'base64 or uint8 arr pub key', 'optional priv key')
  // the instance will encrypt the data with AES/CBC and the given key.
  .withEncryption('encryption key as string', EncryptionAlgorithm.AES)
  // will use hmac, instead of ecdsa. this makes the withECDSASignature obsolote.
  // the second arguments tells the cryptbox to truncate the signature to 8 bytes.
  .withHMACSignature('hmac signature key', 8)
  // builds a cryptbox instance
  .build();

// Note: you don't have to use an encryption nor signature algorithm. both are optional.

async function example(){
  const data = Uint8Array.from([1, 2, 3]);
  // Our cryptbox instance has AES encryption and HMAC signature.
  // So our data will first be encrypted, the iv and salt will be added to the output.
  // Then the hmac signature will be calculated, truncated to 8 bytes, and prepended to the start of the resulting bytes
  // The resulting bytes of data will be encoded to base64.
  const resultBase64 = await cryptbox.protect(data);
  const resultBytes = await cryptbox.protectBinary(data);
  // first checks the signature of the data, if the signature algorithm is enabled
  // then decrypts the data if encryption is enabled
  const unprotected = await cryptbox.unprotect(resultBase64);
  const unprotected2 = await cryptbox.unprotectBinary(resultBytes);
  assert(data.toString() === unprotected.toString() && data.toString() === unprotected2.toString());
}

example().then(console.log, console.log);