Im stuck reverse engineering a piece of java code. I was wondering if someone could help me out!
String var1 = "hello";
String var2 = "123456";
long var_l = 0L;
byte[] a1 = new byte[50];
byte[] a2 = new byte[50];
// i believe this checks if its between a-Z?
for (int j = 0; j < var1.length(); j++)
{
a2[j] = (byte) var1.charAt(j);
if ((a2[j] < 65) || (a2[j] > 122)
{
continue;
}
var_l += 145 + a2[j];
}
The next part i really dont understand
var_l *= a1[0]; // a1 is a byte array of var2
var_l = 0xFFFF & var_l * (0xFF & var_l);
if (var_l < 100L)
{
var_l = 2728L;
}
Could someone please help me out here? Im trying to learn cyphering algorithms here but im having trouble following the logic.
Here is the full code:
param_licensekey & licensename & lictype are global vars. Please read my comment below about the reason why im reverse engineering this. Thanks for all the awnsers.
public boolean check_license()
{
long l = 0L;
byte[] arrayOfByte2 = new byte['ÿ'];
byte[] arrayOfByte1 = new byte['ÿ'];
int i;
if (this.param_licensename.length() >= 2)
{
if (this.param_licensekey.length() >= 2)
{
for (int j = 0; j < this.param_licensekey.length(); j++)
arrayOfByte1[j] = (byte)this.param_licensekey.charAt(j);
for (j = 0; j < this.param_licensename.length(); j++)
{
arrayOfByte2[j] = (byte)this.param_licensename.charAt(j);
if ((this.param_licensename.charAt(j) < 'A') || (this.param_licensename.charAt(j) > 'Z'))
continue;
arrayOfByte2[j] = (byte)(32 + arrayOfByte2[j]);
}
for (j = 0; j < this.param_licensename.length(); j++)
{
if ((arrayOfByte2[j] < 65) || (arrayOfByte2[j] > 122))
continue;
l += 145 + arrayOfByte2[j];
}
l *= arrayOfByte1[0];
l = 0xFFFF & l * (0xFF & l);
if (l < 100L)
l = 2728L;
String str = this.param_licensekey.charAt(0) + l;
if (!this.param_licensekey.startsWith(str))
{
this.lictype = -1;
i = 0;
}
else
{
this.lictype = (i[0] - 48);
i = 1;
}
}
else
{
i = 0;
}
}
else
i = 0;
return i;
}
1 Answer