Rev 11 | Rev 22 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 11 | Rev 14 | ||
---|---|---|---|
Line 835... | Line 835... | ||
835 | wvsprintf (imgfile_pathname, fmt, argptr); |
835 | wvsprintf (imgfile_pathname, fmt, argptr); |
836 | va_end (argptr); |
836 | va_end (argptr); |
837 | 837 | ||
838 | // load the image from file and return the resulting handle |
838 | // load the image from file and return the resulting handle |
839 | return ((HBITMAP) LoadImage (NULL, imgfile_pathname, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)); |
839 | return ((HBITMAP) LoadImage (NULL, imgfile_pathname, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)); |
- | 840 | } |
|
- | 841 | ||
- | 842 | ||
- | 843 | bool IsRegistrationCorrect (const wchar_t *email, const unsigned long code) |
|
- | 844 | { |
|
- | 845 | // quick helper to see if the program is registered. It contains an address to potential crackers. |
|
- | 846 | // Notice: user's email address may be a wchar_t array, and thus may contain Unicode characters. |
|
- | 847 | // /!\ WARNING: THE CRACKER MESSAGE SHOULD NEVER CHANGE, AND NEITHER SHOULD THE ALGORITHM BELOW /!\ |
|
- | 848 | ||
- | 849 | static const char crackermsg[] = "Please, respect my work. DON'T PUBLISH if you crack my program. Thank you and happy cracking :)"; |
|
- | 850 | ||
- | 851 | unsigned long correct_activationcode; |
|
- | 852 | int byte_index; |
|
- | 853 | int length; |
|
- | 854 | ||
- | 855 | // compute the maximal length of the string for which we need to checksum |
|
- | 856 | length = wcslen (email); |
|
- | 857 | if (length > sizeof (crackermsg) - 1) |
|
- | 858 | length = sizeof (crackermsg) - 1; // bound it to the length of the cracker message |
|
- | 859 | ||
- | 860 | // hash the supplied e-mail |
|
- | 861 | correct_activationcode = 5381; // start value |
|
- | 862 | for (byte_index = 0; byte_index < sizeof (crackermsg) - 1; byte_index++) |
|
- | 863 | correct_activationcode = ((correct_activationcode << 5) + correct_activationcode) |
|
- | 864 | + ((unsigned long) (length > 0 ? towlower (email[byte_index % length]) : rand ()) // prevent zero divide |
|
- | 865 | ^ (unsigned long) crackermsg[byte_index]); // hash = hash * 33 + (char(email) ^ char(crackermsg)) |
|
- | 866 | correct_activationcode &= 0x7FFFFFFF; // make sure the results remain positive |
|
- | 867 | ||
- | 868 | // as usuals, it alls boils down to a single test :( |
|
- | 869 | return ((length > sizeof ("a@b.c") - 1) && (code == correct_activationcode)); |
|
840 | } |
870 | } |