You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: encryption.go
    path of file: ./repos/cockroach/pkg/ccl/storageccl
    
    the code of the file until where you have to start completion: // Copyright 2020 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. Yo
    
func (e *encWriter) Write(p []byte) (int, error) {
	var wrote int
	for wrote < len(p) {
		copied := copy(e.buf[e.bufPos:encryptionChunkSizeV2], p[wrote:])
		e.bufPos += copied
		if e.bufPos == encryptionChunkSizeV2 {
			if err := e.flush(); err != nil {
				return wrote, err
			}
		}
		wrote += copied
	}
	return wrote, nil
}