github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/math/rand/v2/chacha8.go (about)

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package rand
     6  
     7  import "github.com/shogo82148/std/internal/chacha8rand"
     8  
     9  // A ChaCha8 is a ChaCha8-based cryptographically strong
    10  // random number generator.
    11  type ChaCha8 struct {
    12  	state chacha8rand.State
    13  }
    14  
    15  // NewChaCha8 returns a new ChaCha8 seeded with the given seed.
    16  func NewChaCha8(seed [32]byte) *ChaCha8
    17  
    18  // Seed resets the ChaCha8 to behave the same way as NewChaCha8(seed).
    19  func (c *ChaCha8) Seed(seed [32]byte)
    20  
    21  // Uint64 returns a uniformly distributed random uint64 value.
    22  func (c *ChaCha8) Uint64() uint64
    23  
    24  // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
    25  func (c *ChaCha8) UnmarshalBinary(data []byte) error
    26  
    27  // MarshalBinary implements the encoding.BinaryMarshaler interface.
    28  func (c *ChaCha8) MarshalBinary() ([]byte, error)