MathNya / umya-spreadsheet

A pure rust library for reading and writing spreadsheet files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

encrypt xlsx file can not open by wps-office

flyInRust opened this issue · comments

after use writer::xlsx::write_with_password to encrypt some xlsx file,the wps-office can't open this file .

and libreoffice can't open the encrypt( writer::xlsx::write_with_password) file too!

@flyInRust
Thank you for your report.
I can confirm that libreoffice does not open encrypted files.
It probably means that there are parts of the specifications regarding encryption that differ from software to software.
It would be difficult to identify the part to be fixed, so it would take some time to modify the program.

can u port the function from the msoffice-crypt ?

i have create a msoffice-crypt rust bind:

msoffice crypt rust

use msoffice_crypt::{encrypt,decrypt};
fn main() {
        let input = "/home/feiy/Desktop/1.xlsx";
        let output = "/home/feiy/Desktop/output.xlsx";
        let password = "test";
        let ret = encrypt(input,password,Some(output));
        println!("{ret:#?}");
        let plain = "/home/feiy/Desktop/plain.xlsx";
        let ret = decrypt(output,password,Some(plain));
        println!("{ret:#?}");
        let plain = "/home/feiy/Desktop/plain.xlsx";
        let ret = encrypt(plain,password,None);
        println!("{ret:#?}");
        
}

@flyInRust
Thank you very much.
I have looked at msoffice crypt rust.
It is a wonderful library.

However, umya-spreadsheet cannot use this library because it must be 100% rust language.

I will refer to it to find the cause of the problem.

this is the encrypt References:
* Compound File Binary File Format(v20120328) MS-CFB
* Office Document Cryptography Structure Specification(v20120412) MS-OFFCRYPTO
* CODE BLUE 2015 Backdoors with the MS Office file encryption master key and a proposal for a reliable file format