private function buildHeaders($key, $keySHA256, $useCopySourceHeaders)
    {
        if ($key) {
            $headerNames = $useCopySourceHeaders
                ? $this->copySourceEncryptionHeaderNames
                : $this->encryptionHeaderNames;

            if (!$keySHA256) {
                $decodedKey = base64_decode($key);
                $keySHA256 = base64_encode(hash('SHA256', $decodedKey, true));
            }

            return [
                $headerNames['algorithm'] => 'AES256',
                $headerNames['key'] => $key,
                $headerNames['keySHA256'] => $keySHA256
            ];
        }

        return [];
    }