Page 1 of 1

RPN algorithm for registration code implementation?

PostPosted: Fri Jun 10, 2005 2:37 pm
by BeyondtheTech
I have actually devised my own registration code system in my upcoming release, Bubble Buster Advanced, however it would have been much easier if an RPN algorithm can be implemented to come up with a registration code, since it's pretty universal now (PocketGear, Handango, and many other sites have it built-in to their own website such that no author intervention is required, other than providing the RPN string).

Here's a full description of the algorithm, C source code, and examples found here:
http://www.mythological.com/regcode/

Reiterated by Handango:
http://www.handango.com/DeveloperInform ... GISTRATION

You can test out any algorithms here:
http://www.handango.com/RegCode.jsp

You can use this program with StyleTap (Palm Emulator for Pocket PC):
http://akeysoft.com/product_details.asp ... 0RPN%20Reg


Can this be implemented in Game Editor?

Code: Select all
example1:
   C/DUI = "Will P"
   RPN string = "i 0 == 111 * key + c 2 * +"
   result: "01151"

PostPosted: Mon Jun 13, 2005 11:39 pm
by makslane
While not in Game Editor, you can, with few modifications, put the RPN code in the Global Code.

You must remove the #include lines, modify the main function to be your entry point function and put the code for strtok function (may be this: http://babbage.cs.qc.edu/courses/cs381.2/strtok.c.html) and other missing functions.

I think will work.

PostPosted: Tue Jun 14, 2005 1:54 am
by BeyondtheTech
Sorry, makslane, my experience in C is still in its infant stages... can anyone else put this together without pulling their hair out?

PostPosted: Tue Jun 14, 2005 4:26 am
by makslane
Ok!

Download a sample at http://game-editor.com/examples/rpn_unlockkey.zip

Use the GetUnlockKey function to get the unlock key from a RPN algorithm and a reg code.

For example:
RPN Algorithm: key c +
Reg Code: 4A:6F:65:1E

char *keyString = GetUnlockKey("key c +", "4A:6F:65:1E");

If there is some error, the keyString will be empty.
In abose sample, keyString will be "00286"


For more information about the RPN algorithm in Global Code visit:
http://www.mythological.com/regcode/

See the copyright info into code.

PostPosted: Tue Jun 14, 2005 6:30 am
by BeyondtheTech
WOW, Makslane... you have just automated the registration process at Handango and PocketGear!! Thank you so much!!

The code was initially created for Palm users, so they were the ones who came up with that obnoxious RegCode hexadecimal string separated by colons and ended with a hex checksum. Handango and PocketGear no longer use that, so I took what common sense I had and hacked the code as necessary:

Increased the stack max size to 100 from 30, to accomodate longer names
#define STACK_MAX_SIZE 100


Increased the PUN string to 100 characters (never should get that long, but there's no limit on Handango on PocketGear, so 100 should be fair):
static char PUN[100];


And just pulled the Registration name (first-100 characters):
char *GetUnlockKey(char *rpn, char *reg_code)
{
char i;
static char keyString[6];

rpn_error[0] = 0;

strcpy(RPNString, rpn);
strncpy(PUN, reg_code,100); This line modified.

/* Parse input and compute Unlock key */

ParseRPNString();
// ComputePUNFromRegCode(RegCode); This line removed/remarked out.
unlockKey = ComputeUnlockKey(PUN/*, stackOperators*/);

/* Return Results */
FormatKey(unlockKey, keyString);

if(rpn_error[0]) return "";

return keyString;
}


Now, all one has to do is:
Code: Select all
actualcode = strcpy(text, GetUnlockKey("i 0 == 111 * key + c 2 * +","Will P");
if (actualcode == codeenteredbyuser) registered=1;


AWESOME!

PostPosted: Tue Jun 14, 2005 12:20 pm
by makslane
One change:
if (strcmp(actualcode, codeenteredbyuser) == 0) registered=1;

PostPosted: Tue Jun 14, 2005 12:47 pm
by BeyondtheTech
Hehe... oops - i was mixing English with C. Thanks again, Makslane... Works like a charm!