Source file src/crypto/internal/cryptotest/hash.go
1 // Copyright 2025 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 cryptotest 6 7 import ( 8 "hash" 9 "internal/testhash" 10 "io" 11 "math/rand" 12 "testing" 13 "time" 14 ) 15 16 type MakeHash func() hash.Hash 17 18 // TestHash performs a set of tests on hash.Hash implementations, checking the 19 // documented requirements of Write, Sum, Reset, Size, and BlockSize. 20 func TestHash(t *testing.T, mh MakeHash) { 21 testhash.TestHash(t, testhash.MakeHash(mh)) 22 } 23 24 func newRandReader(t *testing.T) io.Reader { 25 seed := time.Now().UnixNano() 26 t.Logf("Deterministic RNG seed: 0x%x", seed) 27 return rand.New(rand.NewSource(seed)) 28 } 29