Files
swift-mirror/docs/Random.md
Nate Cook 7a4e0a32f6 [stdlib] Revise documentation
This includes various revisions to the APIs landing in Swift 4.2, including:
- Random and other randomness APIs
- Hashable changes
- MemoryLayout.offset(of:)
2018-05-18 11:31:54 -05:00

623 B

Random APIs

More documentation to come.

Platform-Specific Default Random

The implementation of the default random generator varies by platform. The implementation on each platform must be thread-safe and automatically seeded, and should be cryptographically secure to the extent possible. Currently supported platforms have the following implementation details:

  • Apple platforms use arc4random_buf(3).
  • Linux, FreeBSD, and other UNIX-like platforms use getrandom(2) when available; otherwise, they read from /dev/urandom.
  • Fuchsia platforms use getentropy(3).
  • Windows paltforms use BCryptGenRandom.