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

crossmool

v1.3.1

Published

Crossmool SM2/SM3/SM4 utilities based on sm-crypto-v2 (Java interoperable)

Readme

crossmool

A cross-language toolkit for the Chinese national cryptographic standards SM2 / SM3 / SM4. This is the JavaScript/TypeScript implementation, built on top of sm-crypto-v2.

The name comes from cross [S]M [T]ool: it lets you encrypt in one language and decrypt in another, with a single unified data format across all supported languages (Java, Python, JavaScript, Go, Rust, C, C++, C#).

Features

  • SM2 — asymmetric encryption / decryption, signing / verification, combined encrypt-then-sign
  • SM3 — 256-bit hash and HMAC-SM3 message authentication
  • SM4 — symmetric encryption in GCM mode (authenticated, tamper-evident)
  • Cross-language interop — C1C3C2 ciphertext layout, X.509 public key / PKCS#8 private key (DER), PEM import/export, HEX (default) and Base64 encodings
  • TypeScript-first — full type declarations, ESM + CommonJS + IIFE (browser) builds

Installation

npm install crossmool

Quick start

import { SM2Util, SM3Util, SM4Util } from 'crossmool';

// --- SM2: encrypt / decrypt ---
const { publicKey, privateKey } = SM2Util.generateKeyPairHex();
const ciphertext = SM2Util.encryptToHex('hello 简体中文 繁體中文', publicKey);
const plaintext = SM2Util.decrypt(ciphertext, privateKey);

// --- SM2: sign / verify ---
const signature = SM2Util.signToHex(plaintext, privateKey);
const ok = SM2Util.verify(plaintext, publicKey, signature);

// --- SM3: digest + HMAC ---
const hash = SM3Util.digest(plaintext);            // 64-char HEX
const key = SM3Util.generateHmacKeyToStr();
const mac = SM3Util.hmac(plaintext, key);
const valid = SM3Util.hmacVerify(plaintext, key, mac);

// --- SM4: GCM encrypt / decrypt ---
const sm4Key = SM4Util.generateKeyHex();
const sm4Cipher = SM4Util.encryptGcmString(plaintext, sm4Key);
const sm4Plain = SM4Util.decryptGcmToString(sm4Cipher, sm4Key);

API overview

| Utility | Method | Description | |---------|--------|-------------| | SM2Util | generateKeyPairHex() / generateKeyPairRaw() | Generate key pair (HEX / raw DER) | | | encryptToHex / encryptToBase64 | Encrypt with public key | | | decrypt | Decrypt with private key | | | signToHex / signToBase64 | Sign with private key | | | verify | Verify with public key | | | encryptSign / verifyDecrypt | Combined encrypt-then-sign | | | exportPublicKeyPEM / exportPrivateKeyPEM / importPublicKeyPEM | PEM import/export | | SM3Util | digest / digestToHex | SM3 hash | | | generateHmacKeyToStr / hmac / hmacVerify | HMAC-SM3 | | SM4Util | generateKeyHex / generateKeyBase64 | Generate 128-bit key | | | encryptGcmString / decryptGcmToString | SM4-GCM encrypt/decrypt |

Cross-language interoperability

Data formats are unified across all 8 language implementations:

  • SM2 public key: X.509 (DER), private key: PKCS#8 (DER)
  • SM2 ciphertext: C1C3C2 layout
  • SM4: GCM mode only (IV 12 bytes, tag 128 bits)
  • Output: HEX by default, Base64 optional

For the full function-by-function specification, see userdoc/public_function_specification.md.

Requirements

  • Node.js 22 or newer

License

LGPL-3.0