DocumentBase.PasswordEncryptionKeyLength Property

 

Gets the key length of the algorithm Microsoft Office Word uses when encrypting documents with passwords.

Namespace:   Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public int PasswordEncryptionKeyLength { get; }

Property Value

Type: System.Int32

The key length of the algorithm Microsoft Office Word uses when encrypting documents with passwords.

Use the SetPasswordEncryptionOptions method to specify the key length that Word uses when encrypting documents with passwords.

The following code example sets the password encryption options if the password encryption key length is less than 40. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentPasswordEncryptionKeyLength()
{
    if (this.PasswordEncryptionKeyLength < 40)
    {
        string PasswordEncryptionProvider = "Microsoft RSA SChannel Cryptographic Provider";
        string PasswordEncryptionAlgorithm = "RC4";
        int PasswordEncryptionKeyLength = 56;
        object PasswordEncryptionFileProperties = true;

        this.SetPasswordEncryptionOptions(PasswordEncryptionProvider,
            PasswordEncryptionAlgorithm, PasswordEncryptionKeyLength,
            ref PasswordEncryptionFileProperties);
    }
}
Return to top
Show: