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

isw-crypto-utils

v1.0.6

Published

A utility library for cryptographic operations using crypto-js and elliptic as used at ISW.

Readme

ISW Crypto Utils

License: MIT

A Node.js package providing cryptographic utilities for common tasks such as generating nonces, performing ECDH key exchange, hashing messages, encrypting/decrypting data using AES-256-CBC, and signing/verifying messages using ECDSA. Built with crypto-js and elliptic.


Installation

Install the package using npm:

npm install isw-crypto-utils

Usage

Import the Package

import ISWCryptoUtils from '../node_modules/isw-crypto-utils'
const cryptoUtils = new ISWCryptoUtils();

Generate a Random Nonce

A nonce is a random value used in cryptographic operations. Use the generateNonce() method to generate a 16-byte nonce as a hex string.

const nonce = cryptoUtils.generateNonce();
console.log("Nonce:", nonce);

Generate an ECDH Key Pair

Generate a public/private key pair for Elliptic Curve Diffie-Hellman (ECDH) key exchange using the P-256 curve.

const keyPair = cryptoUtils.generateECDHKeyPair();
console.log("Public Key:", keyPair.publicKey);
console.log("Private Key:", keyPair.privateKey);

Perform ECDH Key Exchange

Derive a shared secret using ECDH. Pass your private key and the other party's public key.

const sharedSecret = cryptoUtils.doECDH(privateKey, remotePublicKey);
console.log("Shared Secret:", sharedSecret);

Hash a Message

Hash a message using SHA-256. The output is a hex string.

const hash = cryptoUtils.hashMessage("Hello, World!");
console.log("Hash:", hash);

Encrypt Data Using AES-256-CBC

Encrypt data using AES-256-CBC. You need a 256-bit key (64 hex characters).


const key = "your-256-bit-key"; // Must be 64 hex characters
const encryptedData = cryptoUtils.encryptAES("Sensitive Data", key);
console.log("Encrypted Data:", encryptedData);

Decrypt Data Using AES-256-CBC

Decrypt data using AES-256-CBC. Use the same key used for encryption.

const decryptedData = cryptoUtils.decryptAES(encryptedData, key);
console.log("Decrypted Data:", decryptedData);

Sign a Message

Sign a message using RSA. Pass the message and your private key.

const signature = cryptoUtils.signMessage("Hello, World!", privateKey);
console.log("Signature:", signature);

Verify a Signature

Verify a message signature using RSA. Pass the message, signature, and the signer's public key.

const isValid = cryptoUtils.verifySignature("Hello, World!", signature, publicKey);
console.log("Signature Valid:", isValid);

API Reference

| Method | Description | | --- | --- | | generateNonce() | Generates a random 16-byte nonce as a hex string. | | generateECDHKeyPair() | Generates an ECDH key pair (public and private keys) using the P-256 curve. | | doECDH(privateKey, publicKey) | Derives a shared secret using ECDH key exchange. | | hashMessage(message) | Hashes a message using SHA-256. | | encryptAES(data, key, iv) | Encrypts data using AES-256-CBC. | | decryptAES(encryptedData, key, iv) | Decrypts data using AES-256-CBC. | | generateIV() | Generates a random 16-byte IV for AES encryption. | | signMessage(message, privateKey) | Signs a message using RSA. | | verifySignature(message, signature, publicKey) | Verifies a message signature using RSA. |


Dependencies

  • crypto-js: For AES encryption/decryption, SHA-256 hashing, and random byte generation.

  • elliptic: For ECDH key exchange and ECDSA signing/verification.


License

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


Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.


Support

If you find this package useful, consider giving it a ⭐️ on GitHub!