@siegesailor/cryptography
v2.3.0
Published
Provide a collection of cryptography functions and a CLI.
Maintainers
Readme
Cryptography
Zero configuration needed. WebAssembly availability is determined at runtime, with a safe fallback to JavaScript with TypeScript support implemented. The library is production-ready, with a focus on security and performance, providing implementations for:
| Algorithm | JavaScript | TypeScript | WebAssembly | | ----------------------------------------------------------------------------- | ---------- | ---------- | ----------- | | Baby Step Giant Step | ✅ | ✅ | ✅ | | Blum Blum Shub | ✅ | ✅ | ✅ | | Chinese Remainder | ✅ | ✅ | ✅ | | Euclidean | ✅ | ✅ | ✅ | | Extended Euclidean | ✅ | ✅ | ✅ | | Fast Modular Exponentiation | ✅ | ✅ | ✅ | | Miller Rabin Primality Test | ✅ | ✅ | ✅ | | Multiplicative Inverse | ✅ | ✅ | ✅ | | Naor Reingo | ✅ | ✅ | ✅ | | Pollard P-1 Factorization | ✅ | ✅ | ✅ | | Pollard Rho | ✅ | ✅ | ✅ | | Primitive Root Search | ✅ | ✅ | ✅ |
And, a CLI is available to interact with these algorithms and demonstrate the 3 key encryption flows:
Installation
The package is available on NPM:
npm install @siegesailor/cryptographyPrerequisites
Required software for this module:
Tested and compatible Node.js versions:
14.18.016.20.218.0.025.2.1
Use as a Library
You can use it in ESM:
import {
fastModularExponentiation,
millerRabinPrimalityTest,
euclidean,
} from "@siegesailor/cryptography";
const gcd = euclidean(614n, 513n);
const modPow = fastModularExponentiation(2n, 100n, 71n);
const isPrime = millerRabinPrimalityTest(104729n, 10);Or, you can use it in CommonJS:
const {
euclidean,
fastModularExponentiation,
millerRabinPrimalityTest,
} = require("@siegesailor/cryptography");Use as a CLI

Run directly with NPX:
npx @siegesailor/cryptography