OfficeEncrypt

Encrypt Office Open XML documents (.xlsx, .docx, .pptx) with a password using ECMA-376 Agile Encryption (AES-256-CBC, SHA-512).

Installation

Add office_encrypt to your list of dependencies in mix.exs:

def deps do
  [
    {:office_encrypt, "~> 0.1.0"}
  ]
end

Usage

{:ok, data} = File.read("document.xlsx")
encrypted = OfficeEncrypt.encrypt(data, "password123")
File.write!("encrypted.xlsx", encrypted)

The encrypted file can be opened with Microsoft Office, LibreOffice, and other compatible applications using the provided password.

Options

OfficeEncrypt.encrypt/3 accepts an optional third argument with options:

OfficeEncrypt.encrypt(data, "password123", spin_count: 1_000_000)

Notes

This library provides encryption only. Decryption is not currently supported.

The resulting files are OLE2 compound documents compatible with Microsoft Office and LibreOffice.

License

MIT