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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。