public protocol SeedableRandomNumberGenerator : RandomNumberGenerator

A type that provides seedable deterministic pseudo-random data.

A SeedableRandomNumberGenerator can be used anywhere where a RandomNumberGenerator would be used. It is useful when the pseudo-random data needs to be reproducible across runs.

Conforming to the SeedableRandomNumberGenerator Protocol

To make a custom type conform to the SeedableRandomNumberGenerator protocol, implement the init(seed: [UInt8]) initializer, as well as the requirements for RandomNumberGenerator. The values returned by next() must form a deterministic sequence that depends only on the seed provided upon initialization.

  • init(seed:)

    Default implementation

    Default Implementation


    init(seed: [UInt8])
  • Declaration

    init<T>(seed: T) where T : BinaryInteger