---
title: "Check an Office file for missing EncryptionInfo in C#"
url: https://recursiveai.org/onedocument/cookbook/check-office-file-for-missing-encryptioninfo/
description: "Seeing ‘ECMA-376 encrypted file missing /EncryptionInfo’? Check the root streams of an Office compound file in C# without decrypting or changing the file."
version: "1.0.0"
---

A `.docx` or `.xlsx` encrypted with ECMA-376 uses a compound file instead of a ZIP: it’s a container of named streams that holds `/EncryptionInfo` and `/EncryptedPackage`.

```shell
dotnet add package RecursiveAI.OneDocument
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneDocument.Cfb;

var path = args.FirstOrDefault()
    ?? "missing-info.cfb";
using var file = CfbPackage.Open(path);
var info = file.FindPart("/EncryptionInfo");
var payload = file.FindPart("/EncryptedPackage");
Console.WriteLine(info is null
    ? "/EncryptionInfo: missing"
    : "/EncryptionInfo: present");
Console.WriteLine(payload is null
    ? "/EncryptedPackage: missing"
    : "/EncryptedPackage: present");
```

Paste the code above into Program.cs of a new `dotnet new console` project and `dotnet run`, or unzip [the example](https://recursiveai.org/onedocument/cookbook/check-office-file-for-missing-encryptioninfo/check-office-file-for-missing-encryptioninfo.zip) and `dotnet run`.

The zip includes `missing-info.cfb`, a synthetic compound file with just one stream: `/EncryptedPackage`, containing the placeholder bytes `01 02 03` in hex, not real ciphertext. Run from the folder containing the sample. The program prints:

```text
/EncryptionInfo: missing
/EncryptedPackage: present
```

To check your own file, pass its path after `dotnet run --`. If the file isn’t a compound file or is too damaged to open, `CfbPackage.Open` throws an `OfficeException` instead of reporting a missing stream.

## Variations

### List every stream path

Add this after the two lookups to see what the directory contains, including streams in nested storages:

```csharp
foreach (var part in file.Parts)
    Console.WriteLine(part.Name);
```

With `missing-info.cfb`, this adds one line:

```text
/EncryptedPackage
```

## Related recipes

- [Open a password-protected Office file in C#](https://recursiveai.org/onedocument/cookbook/open-password-protected-office-file/)
- [Read an Excel file in C#](https://recursiveai.org/onedocument/cookbook/read-excel-file/)

## The short answer

If you see “ECMA-376 encrypted file missing /EncryptionInfo,” open the file as a compound container and check for `/EncryptionInfo` and `/EncryptedPackage` at the root. If `/EncryptedPackage` is present but `/EncryptionInfo` is missing, you’ve confirmed the directory contains an entry for the payload but no entry for the descriptor. The check doesn’t read either stream’s contents, take a password, or attempt recovery.

## What does “ECMA-376 encrypted file missing /EncryptionInfo” mean?

An ordinary `.xlsx`, `.docx`, or `.pptx` is a ZIP package. With ECMA-376 document encryption, the encrypted package is stored inside a compound file: a container with a directory of named streams and storages, like files and folders inside the document. Microsoft’s [Office Document Cryptography Structure, §2.3.4](https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-offcrypto/4f2e28a1-624a-4bed-b3ec-816f0df484ff) describes the wrapper. The `/EncryptedPackage` stream holds the encrypted package; `/EncryptionInfo` describes the encryption. The descriptor has a different structure for [Standard](https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-offcrypto/2895eba1-acb1-4624-9bde-2cdad3fea015) and [Agile](https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-offcrypto/87020a34-e73f-4139-99bc-bbdf6cf6fa55) encryption.

The leading slash in `CfbPackage.FindPart` means “at the root.” A similarly named stream under another storage doesn’t satisfy the lookup. OneDocument looks for an exact name first and then ignores case, so `/encryptioninfo` at the root counts as present. Neither lookup checks the bytes: an empty or malformed descriptor can still have a directory entry.

## What should I do with each result?

Use the output to separate a missing stream from a different problem:

- **Only `/EncryptedPackage` is present.** The expected descriptor isn’t listed. That’s a structural finding, not evidence that the password is wrong or that the file can be decrypted. Check a fresh copy from the sender or source system.
- **Both streams are present.** A missing root descriptor doesn’t explain the failure on this copy. The check says nothing about whether the descriptor or payload is readable or whether the encryption scheme is supported. With a supported, password-protected file, the normal Office reader can distinguish a required or incorrect password from a malformed header; the directory check doesn’t make those distinctions. See [OneDocument’s encryption notes](https://recursiveai.org/onedocument/docs/encryption/).
- **`/EncryptedPackage` is missing.** You haven’t found the expected ECMA-376 payload, even if `/EncryptionInfo` exists. If neither is present, the file may be a different kind of compound document, such as a legacy `.xls`, for which these two entries aren’t the test for encryption.
- **The compound file won’t open.** Don’t interpret that as either stream being missing. An ordinary, unencrypted XLSX is ZIP-based and should go through the workbook reader instead of this check. An unreadable compound container also can’t give you a directory result.
