github.com/quay/claircore@v1.5.28/test/digest.go (about) 1 package test 2 3 import ( 4 "crypto/rand" 5 "crypto/sha256" 6 "io" 7 "testing" 8 9 "github.com/quay/claircore" 10 ) 11 12 // RandomSHA256Digest returns a random Digest. 13 func RandomSHA256Digest(t testing.TB) claircore.Digest { 14 b := make([]byte, sha256.Size) 15 if _, err := io.ReadFull(rand.Reader, b); err != nil { 16 t.Fatal(err) 17 } 18 d, err := claircore.NewDigest("sha256", b) 19 if err != nil { 20 t.Fatal(err) 21 } 22 return d 23 }