4 ms·
What's wrong with seeding with time so long as you do it with nanoseconds?
by omegalulw 5y ago
What's wrong with seeding with time so long as you do it with nanoseconds?
- simias 5y agoThat's not the case here, and even then why bother when modern operating systems have ways to easily get you good quality entropy? If you use a decent random library you won't have to bother reinventing the wheel. I had to generate a 20 char random key string in Rust the other day, I just wrote: rand::thread_rng() .sample_iter(&Alphanumeric) .take(20) .map(char::from) .collect() There. Uniform, decent entropy, explicit, simple.
- kadoban 5y agoYou likely can't get a safe amount of entropy from the available resolution in time. For example, even assuming nanoseconds, that's only log(10^9) bits of entropy if you can guess what second (not that hard, may even be public). That's nowhere near enough. I'd also doubt that many ways you try to get a nanosecond resolution time actually have that resolution, there's probably discrete steps of lower resolution.