calamine icon indicating copy to clipboard operation
calamine copied to clipboard

XLSX with passwords

Open golddranks opened this issue 8 years ago • 1 comments

It seems that no Rust crate at the moment supports encrypted spreadsheets but is there any plans? It seems that password support is by no means a trivial feature, since there are many different schemes to encrypt an XLSX file. I don't even know if some are more common than others: http://poi.apache.org/encryption.html

I think that the Apache POI library is the gold standard standard for supporting stuff: https://github.com/apache/poi

As one step towards a better direction, it would be nice if it could recognize and report the error correctly, as it does with the XLS format.

golddranks avatar Nov 20 '17 13:11 golddranks

It seems that it's possible to get the encryption method from the file like this:

https://github.com/apache/poi/blob/2b4f9448830a532c91d9c41f67241ae89debdcf1/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java#L105

So, either you use XOR padding, or then you can read a versionMajor and a versionMinor from the file (not sure if the DocumentInputStream does something funny in the middle or is it just a representation of the bytes...); then you compare those version numbers and possibly flags to what different formats have...

golddranks avatar Nov 20 '17 14:11 golddranks

I recently came across an xslx file that is reported as CDFV2 Encrypted by file that failed with InvalidArchive error from zip crate which is quite misleading. I guess it would be nice to have a detection for a password protected spreadsheet and return an error at least.

I'm happy to look into this as a contribution if crate authors are seeing such feature as a good addition to calamine. cc: @tafia

saks avatar Nov 15 '23 18:11 saks