如何在C#中打开加密的OOXML文档?

时间:2021-03-15 18:23:31

I want to open encrypted OOXML files, which are stored as streams inside a compound OLE file. Microsoft has an API for OOXML, (OOXML Format SDK 2.0, but it seems to lack a way to manipulate encrypted OOXML documents. So, this breaks into two questions.

我想打开加密的OOXML文件,它们作为流存储在复合OLE文件中。微软有一个OOXML API(OOXML Format SDK 2.0,但它似乎缺乏操纵加密的OOXML文档的方法。所以,这有两个问题。

  • How do you open compound OLE documents in C#? I found this very similar question, (reading compound documents in C#), but I was hoping that there might be a cleaner and more generic way of doing it that I missed.

    如何在C#中打开复合OLE文档?我发现了这个非常相似的问题,(在C#中阅读复合文档),但我希望可能有一种更清洁,更通用的方法,我错过了。

  • Is there a high-level way to decrypt the EncryptedPackage stream within the OLE document? The two best references I've found are Decrypting Office Documents and MS-OFFCRYPTO Examples. "Decrypting Office Documents" seems to decrypt successfully, but it relies on an external DLL (Lyquidity.OleStorage.dll) to open the OLE document and did not work for me. "MS-OFFCRYPTO Examples" has an example in C# to decrypt the stream but uses a C++ example to get the stream. Both these references look like they work, but is there a higher level API that does the same thing?

    是否有一种高级方法来解密OLE文档中的EncryptedPackage流?我发现的两个最佳参考是Decrypting Office Documents和MS-OFFCRYPTO示例。 “解密Office文档”似乎成功解密,但它依赖于外部DLL(Lyquidity.OleStorage.dll)来打开OLE文档并且不适合我。 “MS-OFFCRYPTO示例”在C#中有一个示例来解密流,但使用C ++示例来获取流。这两个引用看起来都有效,但是有更高级别的API可以做同样的事情吗?

1 个解决方案

#1


Short answer: no there is no higher level API. Long answer: the MS-OFFCRYPTO Examples is the best example of how to decrypt it, but you will have to use a library (or make your own) for interacting with the OLE document. There are many libraries for OLE Structured Storage such as OpenMCDF and the library from GemBox Software

简短的回答:没有更高级别的API。答案很长:MS-OFFCRYPTO示例是如何解密它的最佳示例,但您必须使用库(或使自己的)与OLE文档进行交互。 OLE结构化存储有许多库,例如OpenMCDF和GemBox软件库

#1


Short answer: no there is no higher level API. Long answer: the MS-OFFCRYPTO Examples is the best example of how to decrypt it, but you will have to use a library (or make your own) for interacting with the OLE document. There are many libraries for OLE Structured Storage such as OpenMCDF and the library from GemBox Software

简短的回答:没有更高级别的API。答案很长:MS-OFFCRYPTO示例是如何解密它的最佳示例,但您必须使用库(或使自己的)与OLE文档进行交互。 OLE结构化存储有许多库,例如OpenMCDF和GemBox软件库