Share via


DocumentBase.PasswordEncryptionAlgorithm Property

Definition

Gets the algorithm Microsoft Office Word uses for encrypting documents with passwords.

public:
 property System::String ^ PasswordEncryptionAlgorithm { System::String ^ get(); };
public string PasswordEncryptionAlgorithm { get; }
member this.PasswordEncryptionAlgorithm : string
Public ReadOnly Property PasswordEncryptionAlgorithm As String

Property Value

The algorithm Microsoft Office Word uses for encrypting documents with passwords.

Examples

The following code example sets the password encryption to a stronger encryption if the password encryption algorithm in use is "OfficeXor". To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentPasswordEncryptionAlgorithm()
{
    if (this.PasswordEncryptionAlgorithm == "OfficeXor")
    {
        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 DocumentPasswordEncryptionAlgorithm()
    If Me.PasswordEncryptionAlgorithm = "OfficeXor" 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 algorithm that Word uses for encrypting documents with passwords.

Applies to