Random
public class Random
Generates buffers of random bytes.
-
Wraps native call.
Note
CCRNGStatus is typealiased to CCStatus but this routine can only return kCCSuccess or kCCRNGFailure
Declaration
Swift
public class func generate(bytes: UnsafeMutablePointer<UInt8>, byteCount: Int) -> RNGStatus
Parameters
bytes
A pointer to the buffer that will receive the bytes
Return Value
.success
or.rngFailure
as appropriate. -
Generates an array of random bytes.
Throws
.success
or an.rngFailure
on failureDeclaration
Swift
public class func generate(byteCount: Int) throws -> [UInt8]
Parameters
bytesCount
Number of random bytes to generate
Return Value
an array of random bytes
-
A version of generateBytes that always throws an error.
Use it to test that code handles this.
Declaration
Swift
public class func generateBytesThrow(byteCount: Int) throws -> [UInt8]
Parameters
bytesCount
Number of random bytes to generate
Return Value
An array of random bytes