3 #include "zypp/base/Random.h"
7 namespace zypp { namespace base {
9 // Taken from KApplication
12 static bool init = false;
17 int fd = open("/dev/urandom", O_RDONLY|O_CLOEXEC);
18 if (fd < 0 || ::read(fd, &seed, sizeof(seed)) != sizeof(seed))
20 // No /dev/urandom... try something else.
22 seed = rand()+time(0);
24 if (fd >= 0) close(fd);
30 // Taken from KApplication
31 std::string random_string(int length)
33 if (length <=0 ) return std::string();
35 std::string str; str.resize( length );
39 int r=::random() % 62;
44 // so what if I work backwards?