Random
open class Random
Generates buffers of random bytes.
-
Wraps native CCRandomeGenerateBytes call.
:note: CCRNGStatus is typealiased to CCStatus but this routine can only return kCCSuccess or kCCRNGFailure
- return: .Success or .RNGFailure as appropriate.
Declaration
Swift
open class func generateBytes(bytes: UnsafeMutableRawPointer, byteCount: Int ) -> RNGStatus
Parameters
bytes
a pointer to the buffer that will receive the bytes
-
Generates an array of random bytes.
- return: an array of random bytes
Throws
anRNGStatus
on failureDeclaration
Swift
open class func generateBytes(byteCount: Int ) throws -> [UInt8]
Parameters
bytesCount
number of random bytes to generate
-
A version of generateBytes that always throws an error.
Use it to test that code handles this.
- return: an array of random bytes
Declaration
Swift
open class func generateBytesThrow(byteCount: Int ) throws -> [UInt8]
Parameters
bytesCount
number of random bytes to generate