Skip to content

SiegeSailor/Cryptography

Repository files navigation

Cryptography

Conventional Commits

This library provides a collection of cryptography algorithms. It serves as a learning resource (Inspired by Boston University MET CS 789 Cryptography) for understanding the implementation of various cryptographic algorithms and their applications in key encryption flows. The library is also production-ready, with a focus on performance and security, making it suitable for use in real-world applications:

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

Tip

Zero configuration needed. WebAssembly availability is determined at runtime, with a safe fallback to JavaScript with TypeScript support implemented.

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:

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

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors