DocumentBase.PasswordEncryptionKeyLength 属性

定义

获取 Microsoft Office Word 在用密码对文档加密时所用算法的密钥长度。

public int PasswordEncryptionKeyLength { get; }

属性值

Int32

Microsoft Office Word 在用密码对文档加密时所用算法的密钥长度。

示例

如果密码加密密钥长度小于40,则下面的代码示例将设置密码加密选项。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。

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 

注解

使用 SetPasswordEncryptionOptions 方法可指定在用密码对文档加密时,Word 使用的密钥长度。

适用于