Partager via


DocumentBase.PasswordEncryptionKeyLength Property

Definition

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

public:
 property int PasswordEncryptionKeyLength { int get(); };
public int PasswordEncryptionKeyLength { get; }
member this.PasswordEncryptionKeyLength : int
Public ReadOnly Property PasswordEncryptionKeyLength As Integer

Property Value

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

Examples

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);
    }
}
Private Sub DocumentPasswordEncryptionKeyLength()
    If Me.PasswordEncryptionKeyLength < 40 Then
        Dim PasswordEncryptionProvider As String = _
            "Microsoft RSA SChannel Cryptographic Provider"
        Dim PasswordEncryptionAlgorithm As String = "RC4"
        Dim PasswordEncryptionKeyLength As Integer = 56
        Dim PasswordEncryptionFileProperties As Object = True

        Me.SetPasswordEncryptionOptions(PasswordEncryptionProvider, _
            PasswordEncryptionAlgorithm, PasswordEncryptionKeyLength, _
            PasswordEncryptionFileProperties)
    End If
End Sub 

Remarks

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

Applies to