What Changed
If you use the EncryptionType.Strong
encryption type to encrypt a binary file (DOC or XLS), the document will be encrypted by using our custom RC4 CryptoAPI encryption implementation. In previous versions, Office binary document RC4 encryption was used.
Reasons for Change
RC4 CryptoAPI encryption is used as the default encryption method for binary files in Microsoft Office 2013 and higher. It is considered to be more secure than 40-bit RC4 encryption.
How to Revert to Previous Behavior
Select the EncryptionType.Compatible
encryption type if you wish to use the RC4 encryption algorithm to encrypt your DOC / XLS document.
Example 1. Encrypt an XLS file
C#// Specify encryption settings.
EncryptionSettings encryptionSettings = new EncryptionSettings();
// Use RC4 encryption.
encryptionSettings.Type = DevExpress.Spreadsheet.EncryptionType.Compatible;
encryptionSettings.Password = "password";
// Save workbook.
workbook.SaveDocument("Document.xls", DocumentFormat.Xls, encryptionSettings);
Visual Basic' Specify encryption settings.
Dim encryptionSettings As New EncryptionSettings()
' Use RC4 encryption.
encryptionSettings.Type = DevExpress.Spreadsheet.EncryptionType.Compatible
encryptionSettings.Password = "password"
' Save workbook.
workbook.SaveDocument("Document.xls", DocumentFormat.Xls, encryptionSettings)
Example 2. Encrypt a DOC file
C#// Specify encryption settings.
EncryptionSettings encryptionSettings = new EncryptionSettings();
// Use RC4 encryption.
encryptionSettings.Type = DevExpress.XtraRichEdit.API.Native.EncryptionType.Compatible;
encryptionSettings.Password = "password";
// Save document.
document.SaveDocument("Document.doc", DocumentFormat.Doc, encryptionSettings);
Visual Basic' Specify encryption settings.
Dim encryptionSettings As New EncryptionSettings()
' Use RC4 encryption.
encryptionSettings.Type = DevExpress.XtraRichEdit.API.Native.EncryptionType.Compatible
encryptionSettings.Password = "password"
' Save document.
document.SaveDocument("Document.doc", DocumentFormat.Doc, encryptionSettings)