msoffice_crypt is both an executable binary that can be run, and a library that can be used in Rust programs.
Installing the command-line executable
Assuming you have Rust/Cargo installed , run this command in a terminal:
cargo install msoffice_crypt
It will make the msoffice_crypt command available in your PATH if you've allowed the PATH to be modified when installing Rust . cargo uninstall msoffice_crypt uninstalls.
Adding msoffice_crypt library as a dependency
Run this command in a terminal, in your project's directory:
cargo add msoffice_crypt
To add it manually, edit your project's Cargo.toml file and add to the [dependencies] section:
msoffice_crypt = "0.1.6"
The msoffice_crypt library will be automatically available globally.
Read the msoffice_crypt library documentation .
Back to the crate overview .
Readme
msoffice crypt lib
msoffice-crypt bindings for the Rust programming language.
A lib to encrypt/decrypt Microsoft Office Document
requirement
you must add the lib libmsoc.so to the system lib before run the bin app.
1.linux:
libmsoc.so
you must compile the lib youself , read more
export LD_LIBRARY_PATH = some/path/to/libmsoc.so/dir:$ LD_LIBRARY_PATH
2.windows:
msoc.dll
msoc.lib
set PATH=some\p ath\t o\l ibmsoc.dll\d ir ; % PATH %
example
use msoffice_crypt:: { encrypt, decrypt} ;
fn main ( ) {
# encrypt the input to output file
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:#?} " ) ;
# decrypt the input file to output file
let plain = " /home/feiy/Desktop/plain.xlsx" ;
let ret = decrypt ( output, password, Some ( plain) ) ;
println! ( " {ret:#?} " ) ;
// overwrite the input file
let plain = " /home/feiy/Desktop/plain.xlsx" ;
let ret = encrypt ( plain, password, None ) ;
println! ( " {ret:#?} " ) ;
}