static unsigned int gen_challenge(void) { struct { struct timeval tv; clock_t cpu; pid_t pid; u_long hid; uid_t uid; gid_t gid; struct utsname name; } s; memset(&s, 0, sizeof(s)); gettimeofday(&s.tv, 0); uname(&s.name); s.cpu = clock(); s.pid = getpid(); #ifndef __ANDROID__ s.hid = gethostid(); #else s.hid = 0; #endif s.uid = getuid(); s.gid = getgid(); return md_32((char*) &s, sizeof(s)); }
/* * Return random unsigned 32-bit quantity. Use 'type' argument if you * need to generate several different values in close succession. */ guint32 random32(int type) { struct { int type; struct timeval tv; clock_t cpu; pid_t pid; guint32 hid; uid_t uid; gid_t gid; struct utsname name; } s; gettimeofday(&s.tv, 0); uname(&s.name); s.type = type; s.cpu = clock(); s.pid = getpid(); s.hid = gethostid(); s.uid = getuid(); s.gid = getgid(); return md_32((char *)&s, sizeof(s)); }
static unsigned int gen_challenge(void) { struct { struct timespec tv; clock_t cpu; int pid; } s; s.cpu = clock(); clock_gettime(CLOCK_REALTIME, &s.tv); s.pid = getpid(); return md_32((char*) &s, sizeof(s)); }
unsigned int gen_challenge(void) { struct { SYSTEMTIME tv; DWORD cpu; int pid; } s; GetSystemTime(&s.tv); s.cpu = GetTickCount(); s.pid = getpid(); return md_32((char*) &s, sizeof(s)); }
/* * Return random unsigned 32-bit quantity. Use 'type' argument if you * need to generate several different values in close succession. */ unsigned int random32(int type) { struct { int type; struct timeval tv; clock_t cpu; pid_t pid; uint32_t hid; #if HAVE_GETUID uid_t uid; gid_t gid; #endif #if HAVE_UNAME struct utsname name; #endif } s; gettimeofday(&s.tv, 0); #if HAVE_UNAME uname(&s.name); #endif s.type = type; s.cpu = clock(); s.pid = getpid(); #if HAVE_GETHOSTID s.hid = gethostid(); #else s.hid = 1; #endif #if HAVE_GETUID s.uid = getuid(); s.gid = getgid(); #endif return md_32((char *)&s, sizeof(s)); }