github.com/opentofu/opentofu@v1.7.1/internal/encryption/keyprovider/pbkdf2/random_source.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package pbkdf2 7 8 import "testing" 9 10 // testRandomSource is a predictable reader that outputs the test name as a source of randomness. 11 type testRandomSource struct { 12 t *testing.T 13 } 14 15 func (t testRandomSource) Read(target []byte) (int, error) { 16 name := t.t.Name() 17 for i := 0; i < len(target); i++ { 18 target[i] = name[i%len(name)] 19 } 20 return len(target), nil 21 }