Share via


DocumentBase.PasswordEncryptionAlgorithm Property

Gets the algorithm Microsoft Office Word uses for 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)

Syntax

'Declaration
Public ReadOnly Property PasswordEncryptionAlgorithm As String
    Get
public string PasswordEncryptionAlgorithm { get; }

Property Value

Type: System.String
The algorithm Microsoft Office Word uses for encrypting documents with passwords.

Remarks

Use the SetPasswordEncryptionOptions method to specify the algorithm that 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 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 
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);
    }
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace