Rev 81 | Rev 136 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 81 | Rev 83 | ||
|---|---|---|---|
| Line 949... | Line 949... | ||
| 949 | // load the image from file and return the resulting handle |
949 | // load the image from file and return the resulting handle |
| 950 | return ((HBITMAP) LoadImage (NULL, imgfile_pathname, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)); |
950 | return ((HBITMAP) LoadImage (NULL, imgfile_pathname, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)); |
| 951 | } |
951 | } |
| 952 | 952 | ||
| 953 | 953 | ||
| 954 | bool IsRegistrationCorrect (const wchar_t *email, const unsigned |
954 | bool IsRegistrationCorrect (const wchar_t *email, const unsigned __int32 code) |
| 955 | { |
955 | { |
| 956 | // quick helper to see if the program is registered. It contains an address to potential crackers. |
956 | // quick helper to see if the program is registered. It contains an address to potential crackers. |
| 957 | // Notice: user's email address may be a wchar_t array, and thus may contain Unicode characters. |
957 | // Notice: user's email address may be a wchar_t array, and thus may contain Unicode characters. |
| 958 | // /!\ WARNING: THE CRACKER MESSAGE SHOULD NEVER CHANGE, AND NEITHER SHOULD THE ALGORITHM BELOW /!\ |
958 | // /!\ WARNING: THE CRACKER MESSAGE SHOULD NEVER CHANGE, AND NEITHER SHOULD THE ALGORITHM BELOW /!\ |
| 959 | 959 | ||
| 960 | static const char crackermsg[] = "Please, respect my work. DON'T PUBLISH if you crack my program. Thank you and happy cracking :)"; |
960 | static const char crackermsg[] = "Please, respect my work. DON'T PUBLISH if you crack my program. Thank you and happy cracking :)"; |
| 961 | static const wchar_t *blacklist[] = { L"bono@fff.com" }; // those crackers didn't play fair :( |
961 | static const wchar_t *blacklist[] = { L"bono@fff.com" }; // those crackers didn't play fair :( |
| 962 | 962 | ||
| 963 | unsigned |
963 | unsigned __int32 correct_activationcode; |
| 964 | int byte_index; |
964 | int byte_index; |
| 965 | int length; |
965 | int length; |
| 966 | 966 | ||
| 967 | // compute the maximal length of the string for which we need to checksum |
967 | // compute the maximal length of the string for which we need to checksum |
| 968 | length = wcslen (email); |
968 | length = wcslen (email); |
| Line 976... | Line 976... | ||
| 976 | 976 | ||
| 977 | // hash the supplied e-mail |
977 | // hash the supplied e-mail |
| 978 | correct_activationcode = 5381; // start value |
978 | correct_activationcode = 5381; // start value |
| 979 | for (byte_index = 0; byte_index < sizeof (crackermsg) - 1; byte_index++) |
979 | for (byte_index = 0; byte_index < sizeof (crackermsg) - 1; byte_index++) |
| 980 | correct_activationcode = ((correct_activationcode << 5) + correct_activationcode) |
980 | correct_activationcode = ((correct_activationcode << 5) + correct_activationcode) |
| 981 | + ((unsigned |
981 | + ((unsigned __int32) (length > 0 ? towlower (email[byte_index % length]) : 1) // prevent zero divide |
| 982 | ^ (unsigned |
982 | ^ (unsigned __int32) crackermsg[byte_index]); // hash = hash * 33 + (char(email) ^ char(crackermsg)) |
| 983 | correct_activationcode &= 0x7FFFFFFF; // make sure the results remain positive |
983 | correct_activationcode &= 0x7FFFFFFF; // make sure the results remain positive |
| 984 | 984 | ||
| 985 | // as usuals, it alls boils down to a single test :( |
985 | // as usuals, it alls boils down to a single test :( |
| 986 | return ((length > sizeof ("a@b.c") - 1) && (code == correct_activationcode)); |
986 | return ((length > sizeof ("a@b.c") - 1) && (code == correct_activationcode)); |
| 987 | } |
987 | } |