Skip to content

SiegeSailor/Cryptography

Repository files navigation

Cryptography

NPM Version Test Release

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/cryptography

Prerequisites

Required software for this module:

Tested and compatible Node.js versions:

  • 14.18.0
  • 16.20.2
  • 18.0.0
  • 25.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

CLI

Run directly with NPX:

npx @siegesailor/cryptography

About

Provides a collection of cryptography functions and a command line tool with interactive prompts to demonstrate key encryption flows and algorithms.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Contributors