ekg2
|
00001 /* gg_login_hash() copied from libgadu copyrighted under LGPL-2.1 (C) libgadu developers */ 00002 /* cache created by me. */ 00003 static unsigned int gg_login_hash() { 00004 static unsigned int saved_y; 00005 static unsigned char *saved_pos; 00006 static unsigned char saved_zn; 00007 00008 unsigned int y; 00009 unsigned char *password; 00010 00011 if (saved_pos && *saved_pos == saved_zn) { 00012 y = saved_y; 00013 password = saved_pos + 1; 00014 } else { 00015 y = SEED; 00016 password = realpass; 00017 } 00018 00019 /* I have no idea, how to crack/optimize this algo. Maybe someone? */ 00020 do { 00021 register unsigned char zn = *password; 00022 register unsigned char z; 00023 00024 y ^= zn; 00025 y += zn; 00026 00027 y ^= (zn << 8); 00028 y -= (zn << 16); 00029 y ^= (zn << 24); 00030 00031 z = y & 0x1F; 00032 y = (y << z) | (y >> (32 - z)); 00033 00034 if (*(++password)) { 00035 y ^= (zn << 24); 00036 y += (zn << 24); 00037 00038 if (password[1] == '\0') { 00039 saved_y = y; 00040 saved_zn = zn; 00041 saved_pos = &password[-1]; 00042 } 00043 } 00044 } while (*password); 00045 00046 #if ULTRA_DEBUG 00047 printf("%s -> 0x%x\n", realpass, y); 00048 #endif 00049 return y; 00050 } 00051