func TestEncryptSectioned(t *testing.T) {
	data := make([]byte, 4096)
	c, err := crand.Read(data)
	if err != nil {
		t.Fatal(err)
	}
	if c < 4096 {
		t.Fatalf("short read %d", c)
	}

	key := make([]byte, encryption.KeyLength)
	c, err = crand.Read(key)
	if err != nil {
		t.Fatal(err)
	}
	if c < encryption.KeyLength {
		t.Fatalf("short read %d", c)
	}

	enc := encryption.New(key, 0, uint32(42), sha3.NewLegacyKeccak256)
	whole, err := enc.Encrypt(data)
	if err != nil {
		t.Fatal(err)
	}

	enc.Reset()
	for i := 0; i < 4096; i += encryption.KeyLength {
		cipher, err := enc.Encrypt(data[i : i+encryption.KeyLength])
		if err != nil {
			t.Fatal(err)
		}
		wholeSection := whole[i : i+encryption.KeyLength]
		if !bytes.Equal(cipher, wholeSection) {
			t.Fatalf("index %d, expected %x, got %x", i/encryption.KeyLength, wholeSection, cipher)
		}
	}
}
// TestEncryptSectioned tests that the cipherText is the same regardless of size of data input buffer
TestEncryptSectioned tests that the cipherText is the same regardless of size of data input buffer
// TestEncryptSectioned tests that the cipherText is the same regardless of size of data input buffer
func TestEncryptSectioned(t *testing.T) {
	data := make([]byte, 4096)
	c, err := crand.Read(data)
	if err != nil {
		t.Fatal(err)
	}
	if c < 4096 {
		t.Fatalf("short read %d", c)
	}
	key := make([]byte, encryption.KeyLength)
	c, err = crand.Read(key)
	if err != nil {
		t.Fatal(err)
	}
	if c < encryption.KeyLength {
		t.Fatalf("short read %d", c)
	}
	enc := encryption.New(key, 0, uint32(42), sha3.NewLegacyKeccak256)
	whole, err := enc.Encrypt(data)
	if err != nil {
		t.Fatal(err)
	}
	enc.Reset()
	for i := 0; i < 4096; i += encryption.KeyLength {
		cipher, err := enc.Encrypt(data[i : i+encryption.KeyLength])
		if err != nil {
			t.Fatal(err)
		}
		wholeSection := whole[i : i+encryption.KeyLength]
		if !bytes.Equal(cipher, wholeSection) {
			t.Fatalf("index %d, expected %x, got %x", i/encryption.KeyLength, wholeSection, cipher)
		}
	}
}
func TestEncryptSectioned ( t * testing . T ) { data := make ( [ ] byte , 4096 ) c , err := crand . Read ( data ) if err != nil { t . Fatal ( err ) } if c < 4096 { t . Fatalf ( " " , c ) } key := make ( [ ] byte , encryption . KeyLength ) c , err = crand . Read ( key ) if err != nil { t . Fatal ( err ) } if c < encryption . KeyLength { t . Fatalf ( " " , c ) } enc := encryption . New ( key , 0 , uint32 ( 42 ) , sha3 . NewLegacyKeccak256 ) whole , err := enc . Encrypt ( data ) if err != nil { t . Fatal ( err ) } enc . Reset ( ) for i := 0 ; i < 4096 ; i += encryption . KeyLength { cipher , err := enc . Encrypt ( data [ i : i + encryption . KeyLength ] ) if err != nil { t . Fatal ( err ) } wholeSection := whole [ i : i + encryption . KeyLength ] if ! bytes . Equal ( cipher , wholeSection ) { t . Fatalf ( " " , i / encryption . KeyLength , wholeSection , cipher ) } } }
TestEncryptSectioned tests that the cipherText is the same regardless of size of data input buffer
TestEncryptSectioned tests that the cipherText is the same regardless of size of data input buffer