注册机 (1千字)
//Note: only English characters allowed.// so you can't use your Chinese name :-(
#include <stdio.h>
#include <string.h>
long java_lang_String_hashCode(char *str);
void main(void)
{
char Name[128];
char Country[128];
long NameCode, CountryCode, AllCode, Code;
printf("KeyGen for NMI's Java Code Viewer 4.8.2.\n");
printf("Input your name: ");
gets(Name);
printf("Input your country: ");
gets(Country);
NameCode = java_lang_String_hashCode(Name);
CountryCode = java_lang_String_hashCode(Country);
AllCode = java_lang_String_hashCode(strcat(Name, Country));
Code = NameCode * CountryCode + AllCode;
Code -= strlen(Name);
if (Code < 0)
{
Code = -Code;
}
printf("You code: %lu\n", Code);
}
long java_lang_String_hashCode(char *str)
{
int k, len, edi,step;
long result;
if (str == NULL)
{
return 0;
}
result = 0;
len = strlen(str);
if (len < 0x10)
{
for (k = 0; k < len; k++)
{
result *= 37;
result += (long)str[k] & 0xFF;
}
}
else
{
k = 0;
step = (len >> 3);
edi = len;
do
{
edi -= step;
result *= 0x27;
result += (long)str[k];
k += step;
} while (edi > 0);
}
return result;
}
