Pin Number Function
Posted: Fri May 19, 2006 6:46 am
I have been thinking of a simle way to get a pin-number out of a string, for use in registration. I have developed a simple solution, but the problem is, how good is it? How easy would it be to figure out? I am thinking it may not be that good for those reasons, but I want peoples opinions. Here is what I'm using:
You can adjust the integers 52, 75 and 54 to customize it. You can also adjust what returnval is set to, but this won't change much. This will determine a number for each string you enter. To test, use two text actors, one with text input. On keydown enter, textNumber = getkey(Enter.text). Then you can test various results.
- Code: Select all
int getkey(char *Enter)
{
int enterlength = strlen(Enter);
char entered[10000];
int i;
int returnval = 0;
for (i = 0; i < enterlength; i++)
{
returnval += ((entered[i] / 52) + 75) * 54;
}
return returnval;
}
You can adjust the integers 52, 75 and 54 to customize it. You can also adjust what returnval is set to, but this won't change much. This will determine a number for each string you enter. To test, use two text actors, one with text input. On keydown enter, textNumber = getkey(Enter.text). Then you can test various results.