SodiumRandom
struct SodiumRandom
A wrapper for generating random bytes securely.
-
The initializer is disabled.
Declaration
Swift
fileprivate init() -
Write random bytes into a memory region.
Precondition
0 ≤
sizeInBytesDeclaration
Swift
func bytes(_ pointer: UnsafeMutableRawPointer, sizeInBytes: Int)Parameters
pointerA pointer to the memory region.
sizeInBytesThe amount of bytes that should be written.
-
Generate a randomly filled byte array.
Declaration
Swift
func bytes(count: Int) -> BytesParameters
countThe size of the byte array in bytes.
Return Value
The byte array.
-
Generate a random number.
Declaration
Swift
func number() -> UInt32Return Value
The random number.
-
Generates a random number with uniform distribution.
Declaration
Swift
func uniform(upperBound: UInt32) -> UInt32Parameters
upperBoundThe upper bound.
Return Value
A random number between 0 and
upperBound.
View on GitHub
SodiumRandom Structure Reference