2

What method does Office 2007 use for encryption (when choosing Encrypt and setting a password from Office menu)?

My C# app needs to create and read encrypted Excel 2007 files (.xlsx). It is important that these files remain accessible from Excel, so I must use Microsoft's encryption method, can't brew my own.

Normal Excel 2007 file is a ZIP-compressed file, and I'm accessing it using ExcelPackage, which internally uses * System.Io.Packaging.Package* (part of .net 3.0).

However, the encryption in Office is not the standard ZIP encryption. The Package class seems not to support encryption, and reports a corrupted file. 7Zip opens the file (with no password provided) and shows a few binary files inside.

Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
dbkk
  • 12,643
  • 13
  • 53
  • 60

3 Answers3

3

Office 2007 uses an OLE document (the same container format that is used for the binary Office documents) to store encrypted documents.

[MS-OFFCRYPTO]: Office Document Cryptography Structure Specification should contain the specification of the used data structures and algorithms.

Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316
  • 1
    Thanks. That's a rather long spec. I'm still hoping for a black box :) – dbkk Oct 01 '09 at 09:33
  • Well, one black box you can use would be to automate Office. But I don't know about any third-part library that can handle encryption. – Dirk Vollmar Oct 01 '09 at 09:35
2

Based on several open source bits and pieces, I created a OoXmlCrypto stream wrapper to access Office 2007 encrypted files easily.

This is based on a blog post with source code which does OOXML encryption/decryption.

dbkk
  • 12,643
  • 13
  • 53
  • 60
1

JFYI: our SecureBlackbox product offers components for encryption and decryption of OOXML documents among many other functions.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121