differences between random and urandom

前端 未结 4 1023
[愿得一人]
[愿得一人] 2020-12-12 20:37

I\'m trying to find out the differences between /dev/random and /dev/urandom files

  1. What are the differences between /dev/random
4条回答
  •  有刺的猬
    2020-12-12 21:10

    Always use /dev/urandom.

    /dev/urandom and /dev/random use the same random number generator. They both are seeded by the same entropy pool. They both will give an equally random number of an arbitrary size. They both can give an infinite amount of random numbers with only a 256 bit seed. As long as the initial seed has 256 bits of entropy, you can have an infinite supply of arbitrarily long random numbers. You gain nothing from using /dev/random. The fact that there's two devices is a flaw in the Linux API.

    If you are concerned about entropy, using /dev/random is not going to fix that. But it will slow down your application while not generating numbers anymore random than /dev/urandom. And if you aren't concerned about entropy, why are you using /dev/random at all?

    Here's a much better/indepth explanation on why you should always use /dev/urandom: http://www.2uo.de/myths-about-urandom/

    The kernel developers are discussing removing /dev/random: https://lwn.net/SubscriberLink/808575/9fd4fea3d86086f0/

提交回复
热议问题