Big Integers in JavaScript Home | Machine Learning | Crypto | Graphics Passphrase Generator | Self-Decrypting Email | Visual Crypto | BigInts

This page demonstrates a JavaScript library for arbitrary-precision integers, BigInt.js. This page performs RSA in any base. In base 95, the message can be ordinary text. Click all the buttons in order to perform all the steps of RSA key generation, encryption, and decryption. Or just click the DO EVERYTHING button.

 Time (sec) Display numbers in: Base 2 (binary) Base 10 (decimal) Base 16 (hexadecimal) Base 64 (digits, letters, "=" and "_") Base 95 (all keys except TAB, ENTER) Base 2^? (how it is stored in memory) The plaintext message: m= The public exponent: e= p, q: bits each p= probable primes true primes q= n= phi= d= c= m'= m''= m'' uses secret p and q to be faster. P=c^d mod p Q=c^d mod q m''=((Q-P)*(p^-1) mod q)*p+P

The library allows addition, subtraction, multiplication, division, exponentiation, and inverses modulo an arbitrary number. It has the extended Euclid algorithm, and can convert between bases up to base 95. It can generate both true prime numbers and probable primes (which have a probability less than 2^-80 of being composite). It uses the built-in JavaScript random number generator, which must be replaced for any crypto or security application.

It will run faster on a browser with a good JavaScript compiler. As of 2009, that means Microsoft Internet Explorer is slow, but all the other major browsers are fast (Firefox, Safari, Chrome, Opera).

It's hard to imagine any practical cryptographic use for this code, other than pedagogical. As of 2009, the major browsers give warning messages if it runs more than a few seconds. A web page is susceptible to Man In The Middle (MITM) attacks. A MITM can modify a web page as it's downloading, inserting code to capture passwords etc. as they're typed, and send them back to the MITM. Even SSL adds little security, since users ignore certificate warnings. This page was just written for my entertainment, after seeing a request for something like this on sci.crypt.

(c) 2000-2009 Leemon Baird