Recent

Author Topic: Very early support for .xlsx protection [PATCH]  (Read 11698 times)

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Very early support for .xlsx protection [PATCH]
« Reply #15 on: March 14, 2017, 11:17:49 pm »
r5806 contains the xlsx decryption. I added a new package laz_fpspreadsheet_crypto which depends on DCPCrypt as the main encryption/decryption engine. It will contain the dedicated units for the fpspreadsheet file formats, as wel as specialized reader/writer units which will have to do the decryption work and pass the stream to the standard reader; the same shouild happen with the writer (not available yet). The new reader/writer is registered as being user-defined, it can be selected by its ID - sifidOOXML instead of sfOOXML.

All the file/stream reading routines of fpspreadsheet needing the format id were extended to accept an optional password. The readers in the basic package laz_fpspreadsheet ignore the password, but those in laz_fpspreadsheet_crypto have to use it to do their work.

In the directory examples/read_write there is a new folder ooxmldemo_crypto which contains a simple console program to read an encrypted and a protected workbook written by Excel2007 (the protected workbook is also encrypted by means of an Excel-internal password). Both files are provided, their password is "test".

The basic procedure to load an encrypted xlsx file is as follows:
  • Add package laz_fpspreadsheet_crypto as a requirement to the program
  • Add unit xlsxooxml_crypto to the uses clause, instead of xlsxooxml.
  • In the workbook's call to ReadFromFile or ReadFromStream use the format ID sfidOOXML (instead of sfOOXML).
  • In case of the file-encrypted workbook, specify the password in ReadFromStream after the format ID. No password is needed to decrypt the protected workbook. The decrypting reader accepts also normal, non-encrypted files.
As shobits1 wrote above, it must be expected that the decryption only works for files written by Excel 2007 and 2010.

 

TinyPortal © 2005-2018