码迷,mamicode.com
首页 > 其他好文 > 详细

/dev/random vs /dev/urandom

时间:2014-11-08 18:05:30      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:io   ar   os   sp   for   on   ad   linux   as   

If you want random data in a Linux/Unix type OS, the standard way to do so is to use /dev/random or /dev/urandom. These devices are special files. They can be read like normal files and the read data is generated via multiple sources of entropy in the system which provide the randomness.

/dev/random will block after the entropy pool is exhausted. It will remain blocked until additional data has been collected from the sources of entropy that are available. This can slow down random data generation.

/dev/urandom will not block. Instead it will reuse the internal pool to produce more pseudo-random bits.

/dev/urandom is best used when:

  • You just want a large file with random data for some kind of testing.
  • You are using the dd command to wipe data off a disk by replacing it with random data.
  • Almost everywhere else where you don’t have a really good reason to use /dev/random instead.

/dev/random is likely to be the better choice when:

  • Randomness is critical to the security of cryptography in your application – one-time pads, key generation.

/dev/random vs /dev/urandom

标签:io   ar   os   sp   for   on   ad   linux   as   

原文地址:http://www.cnblogs.com/bittorrent/p/4083581.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!