Skip to content

Encryption

firegloves edited this page Jul 20, 2022 · 1 revision

Encryption

Since v1.5 MemPOI supports encryption of workbooks, both for binary and xml-based files. As shown in this example, to encrypt a document you must provide at least the password, MemPOI will automatically apply the EncryptionMode.agile:

MempoiEncryption mempoiEncryption = MempoiEncryption.MempoiEncryptionBuilder.aMempoiEncryption()
        .withPassword("my_password")
        .build();

MemPOI memPOI = MempoiBuilder.aMemPOI()
        .withFile(fileDest)
        .addMempoiSheet(new MempoiSheet(prepStmt))
        .withMempoiEncryption(mempoiEncryption)
        .build();

Optionally you can set the EncryptionInfo to use in the encryption process. When MemPOI receives an EncryptionInfo, it passes the information directly to the Apache POI API, without applying any customization to the encryption process.

MempoiEncryption mempoiEncryption = MempoiEncryption.MempoiEncryptionBuilder.aMempoiEncryption()
        .withPassword("my_password")
        .withEncryptionInfo(new EncryptionInfo(EncryptionMode.cryptoAPI)
        .build();

MemPOI memPOI = MempoiBuilder.aMemPOI()
        .withFile(fileDest)
        .addMempoiSheet(new MempoiSheet(prepStmt))
        .withMempoiEncryption(mempoiEncryption)
        .build();

MemPOI encryption relies on the Apache POI one, so it obeys every rule defined by Apache POI APIs.

Clone this wiki locally