forked from TrueCloudLab/restic
Fix RandomReader
This commit is contained in:
parent
f53008d916
commit
109a120b39
2 changed files with 2 additions and 5 deletions
|
@ -133,7 +133,6 @@ func TestLargeEncrypt(t *testing.T) {
|
|||
|
||||
func BenchmarkEncryptWriter(b *testing.B) {
|
||||
size := 8 << 20 // 8MiB
|
||||
rd := RandomReader(23, size)
|
||||
|
||||
k := crypto.NewRandomKey()
|
||||
|
||||
|
@ -141,7 +140,7 @@ func BenchmarkEncryptWriter(b *testing.B) {
|
|||
b.SetBytes(int64(size))
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
rd.Seek(0, 0)
|
||||
rd := RandomReader(23, size)
|
||||
wr := crypto.EncryptTo(k, ioutil.Discard)
|
||||
n, err := io.Copy(wr, rd)
|
||||
OK(b, err)
|
||||
|
@ -195,14 +194,13 @@ func BenchmarkEncryptDecryptReader(b *testing.B) {
|
|||
k := crypto.NewRandomKey()
|
||||
|
||||
size := 8 << 20 // 8MiB
|
||||
rd := RandomReader(23, size)
|
||||
|
||||
b.ResetTimer()
|
||||
b.SetBytes(int64(size))
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
for i := 0; i < b.N; i++ {
|
||||
rd.Seek(0, 0)
|
||||
rd := RandomReader(23, size)
|
||||
buf.Reset()
|
||||
wr := crypto.EncryptTo(k, buf)
|
||||
_, err := io.Copy(wr, rd)
|
||||
|
|
|
@ -90,7 +90,6 @@ type rndReader struct {
|
|||
}
|
||||
|
||||
func (r *rndReader) Read(p []byte) (int, error) {
|
||||
fmt.Printf("Read(%v)\n", len(p))
|
||||
for i := range p {
|
||||
p[i] = byte(r.src.Uint32())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue