I was hoping to be able to calculate the hash of the encrypted data in parallel, but it seems like using a multiple writer as below, the hash is being calculate with plaintext bytes.
Anyone know how I can use a single copy to achieve both encrypting the data and hashing it?
writer := &cipher.StreamWriter{S: cipher.NewCTR(block, iv), W: writeFile}
writeFile.Write(iv)
if _, err := io.Copy(io.MultiWriter(writer, hash), readFile); err != nil {
fmt.Println("error during crypto: " + err.Error())
return "", err
}