<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">For some reason, when we were trying to test this the other day in irc, srandom()/random() weren't available (dunno why, because googling for linux man pages shows it should be), which is why we fell back to rand/srand.</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Jan 21, 2016, at 2:24 PM, Jens Alfke <<a href="mailto:jens@mooseyard.com" class="">jens@mooseyard.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 21, 2016, at 1:00 PM, Erica Sadun via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">* In terms of cross-platform random numbers, there are any number of third party libraries and you can use rand() on many platforms</div></div></blockquote></div><br class=""><div class="">rand() is deprecated because it uses a poor algorithm that doesn’t provide enough randomness. From the random(3) man page:</div><div class=""><br class=""></div><div class=""> The random() and srandom() functions have (almost) the same calling<br class=""> sequence and initialization properties as the rand(3) and srand(3) func-<br class=""> tions. The difference is that <b class="">rand(3) produces a much less random<br class=""> sequence -- in fact, the low dozen bits generated by rand go through a<br class=""> cyclic pattern.</b> All of the bits generated by random() are usable. For<br class=""> example, `random()&01' will produce a random binary value.<br class=""><br class=""></div><div class="">I’d forgotten that random()s sidekick function srandomdev() seeds the RNG with a cryptographic source of entropy, making it usable for secure purposes. So these would be good functions to implement a Swift RNG with.</div><div class=""><br class=""></div><div class="">—Jens</div></div></div></blockquote></div><br class=""></body></html>