Encrypt and Decrypt Excel files with Golang via C++
Microsoft Excel (97–365) enables you to encrypt and password‑protect your spreadsheets. It uses algorithms provided by a cryptographic service provider (CSP), a set of cryptographic algorithms with different properties. The default CSP is “Office 97/2000 Compatible” or “Weak Encryption (XOR)”. It’s important to choose the proper encryption key length. Some CSPs don’t support more than 40 or 56 bits. That is considered weak encryption. For strong encryption, a minimum key length of 128 bits is required. Microsoft Windows contains CSPs that offer strong encryption types as well, for example the “Microsoft Strong Cryptographic Provider”. To give you an idea, 128‑bit encryption is what banks use to secure connections with their online banking systems.
Aspose.Cells allows you to encrypt and password‑protect Microsoft Excel files with your desired encryption type.
Using Microsoft Excel
To set file encryption settings in Microsoft Excel (here Microsoft Excel 2003):
- From the Tools menu, select Options. A dialog will appear.
- Select the Security tab.
- Enter a password and click Advanced.
- Choose the encryption type and confirm the password.
Encrypting Excel file with Aspose.Cells
The following example shows how to encrypt and password‑protect an Excel file using the Aspose.Cells API.
Specifying the “Password to modify” Option
The following example shows how to set the Password to modify Microsoft Excel option for an existing file using the Aspose.Cells API.
Decrypting Excel file with Aspose.Cells
It is very easy to open a password‑protected Excel file and decrypt it using the Aspose.Cells API, as shown in the following code: