RSA and ECC in JavaScript http://www-cs-students.stanford.edu/~tjw/jsbn/
Source Code
The API for the jsbn
library closely resembles that of the java.math.BigInteger class in Java. For example:
x = new BigInteger("abcd1234", 16);
y = new BigInteger("beef", 16);
z = x.mod(y);
alert(z.toString(16));
will print b60c
.