Expand description
Pure Rust library to decrypt password-protected MS Office files.
§Example
This crate exposes two functions: decrypt_from_file
and decrypt_from_bytes
, which do exactly what they say they do. The resulting bytes can then be interpreted by any MS Office parser like docx or calamine.
use docx::DocxFile;
use office_crypto::decrypt_from_file;
use std::io::Cursor;
let path = "protected.docx";
let decrypted: Vec<u8> = decrypt_from_file(path, "Password1234_").unwrap();
let docx = DocxFile::from_reader(Cursor::new(decrypted)).unwrap();
let docx = docx.parse().unwrap();
// Now we can access the docx content
§Formats
-
ECMA-376 (Agile Encryption/Standard Encryption)
- MS-DOCX (OOXML) (Word 2007-Present)
- MS-XLSX (OOXML) (Excel 2007-Present)
- MS-PPTX (OOXML) (PowerPoint 2007-Present)
-
Office Binary Document RC4 CryptoAPI
- MS-DOC (Word 2002, 2003, 2004)
- MS-XLS (Excel 2002, 2003, 2004)
- MS-PPT (PowerPoint 2002, 2003, 2004)
- ECMA-376 (Extensible Encryption)
Agile encrypted files that use non-SHA512 hash functions will yield DecryptError::Unimplemented
, though I haven’t yet encountered such a file.
Note that the latest version of Word will create an Agile encrypted document.
Enums§
Functions§
- decrypt_
from_ bytes - Decrypt bytes as an MS Office file, returning the decrypted bytes.
- decrypt_
from_ file - Open and decrypt an MS Office file, returning the decrypted bytes.