全部博文(2005)
分类:
2008-12-29 15:04:40
// Copyright 2008 luther.gliethttp #include #include #include int main(int argc, char *argv[]) { int fd; char buf[256]; int value; int i; struct timeval tv; fd = open("/dev/random", O_RDONLY | O_NONBLOCK); if (fd == -1) fd = open("/dev/urandom", O_RDONLY | O_NONBLOCK); if (read(fd, buf, 256) > 0) { } gettimeofday(&tv, 0); value = tv.tv_sec + tv.tv_usec; for (i = 0;i < 256;i++) { value += value*0xdeec + buf[i]; } printf("%u", value); close(fd); } |