I am trying to implement a RSA encryption program in flash. I looked into working with Big Numbers and found the BigInteger var type in the Crypto package. I started playing around with BigIntegers but my outputs are never the correct answer. For example the below code will output 5911 when the answer should be 9409. Any input about this error would be great.
var temp:BigInteger = new BigInteger(String(97));
temp = temp.pow(2);
trace(temp.toString());
Output = 5911
I'm not sure which crypto package you are referring to, I though it was as3crypto but I don't remember it's implementions having a
pow
method that has that signature. But either way, you always have to remember what base you are dealing with and what the library was designed for.(9716)2 = 591116
You are dealing with hex, not decimal, numbers.
Think of that geek-is-chic tshirt that says "There are 10 kinds of people. Those that understand binary and those that don't". In that case "10" is assumed to be 102. Which equals 210. Unqualified bases almost always ruin everybodys day.