tags:

views:

17

answers:

1

I'm trying to take an existing Java application, specifically, the formula used to generate a key code, and convert it to a PHP function, so that license keys can be generated on the fly on a web server.

I'm running into issues getting Java instructions converted to PHP functions. Can anyone explain to me what these two lines of code are doing?

public static final long KEY = 0xb2a3453282e55938L;
long no = Long.parseLong(sNo);
A: 

The first line declares a constant that stores a literal value (in this case a long -- or 64-bit integer) with the value given in hexadecimal. In practice, you will do just fine thinking of this value as just another variable, though there are of course technical differences (the value can't be modified and is known at compile-time).

The second line converts a string sNo into a 64-bit integer (long). i.e. "1234" -> 1234. It stores this value into a local variable named no.

Kirk Woll
Ok. The second line makes sense now. You wouldn't happen to know how the first line would be implemented? Is "Key" a variable? This "Key" value doesn't appear anywhere else in the formula I was given. I'm guessing it's somehow used to translate/modify the key code (the final outputted value). Not sure where or how though.
matthewpavkov