Log in

View Full Version : java BigInteger


neur0n
November 23rd, 2004, 13:12
I have a program with following registration check.

regData = new BigInteger(encryptedLicense, 36);
decoded = regData.modPow(e, n);
realData = new String(decoded.toByteArray());
and then check for correct values

Since n is 1598 bit long only way to keygen it is to replace n.
I generated my own n and thought it would be piece of cake but I was wrong.

Problem is that realData must contain character '\' because it is a delimiter.

I was gonna use this code for keygen.

licString = "name\\company\\serial";
m = new BigInteger (licString,36);
c = m.modPow(d,n);
license = new String(c.toByteArray());

Problem is that java BigInteger constructor doesn't accept string with char '\' for radix 36. It takes only small characters and numbers.

How can I create BigInteger from licString ?

I don't want to make other changes to the apllication except changing n.

Solomon
November 23rd, 2004, 20:15
Your plaintext need NOT to be base36 string. Can be base256 string(e.g byte array).

licString = "name\\company\\serial";
m = new BigInteger (licString, 256); //or m = new BigInteger (licString.toByteArray());
c = m.modPow(d,n);
license = new String(c.toByteArray()); //should be license = c.toString(36);

neur0n
November 24th, 2004, 07:43
Thanks for help. Now it works fine .