DocumentBase.PasswordEncryptionKeyLength 屬性

取得 Microsoft Office Word 以密碼加密文件時使用的演算法金鑰長度。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

語法

'宣告
Public ReadOnly Property PasswordEncryptionKeyLength As Integer
public int PasswordEncryptionKeyLength { get; }

屬性值

型別:System.Int32
Microsoft Office Word 以密碼加密文件時使用的演算法金鑰長度。

備註

使用 SetPasswordEncryptionOptions 方法,指定 Word 以密碼加密文件時使用的金鑰長度。

範例

下列範例中,如果密碼加密金鑰長度少於 40 個字元,程式碼會設定密碼加密選項。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

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 
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);
    }
}

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間