<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 21, 2016, at 12:07 PM, Lukas Stabe via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span 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; float: none; display: inline !important;" class="">In addition to not being very obvious, arc4random is also not supported on platforms other than OSX.</span><br 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;" class=""></div></blockquote><div><br class=""></div><div>It’s also available in OpenBSD and FreeBSD.</div><br class=""><blockquote type="cite" class=""><div class=""><span class="" style="font-family: Alegreya-Regular; float: none; display: inline !important;">Be aware that the generators are not able to produce cryptographically secure random, and I’m pretty new to this field. I basically just ported some generators from&nbsp;</span><a href="http://xorshift.di.unimi.it/" class="" style="font-family: Alegreya-Regular;">http://xorshift.di.unimi.it/</a><span class="" style="font-family: Alegreya-Regular; float: none; display: inline !important;">&nbsp;to Swift.</span></div></blockquote></div><br class=""><div class="">In general it’s better to provide a cryptographically-safe RNG, so people can’t accidentally use an insecure one in a context that needs security. Since every OS provides one of these, I think it’d be best for Swift to provide a single RNG API whose implementation calls the platform’s RNG.</div><div class=""><br class=""></div><div class="">—Jens</div></body></html>