开发者

/dev/urandom maximum size

If you want to read N bytes guaranteed from /dev/urandom, is it safe to perform a single read call and be guaranteed you get N bytes - or are there some operating systems that don't provide that guarantee, and may pr开发者_如何学运维oduce a short read from /dev/urandom?


A read from /dev/urandom may return before being fully satisfied if interrupted by a signal.


To be safe, I would not assume that full reads are guaranteed, and instead read repeatedly until you have as much data as you need. You never know when some implementation is going to decide that short reads from /dev/urandom are fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜