Sdílet prostřednictvím


WorkbookBase.PasswordEncryptionAlgorithm – vlastnost

Získá algoritmus, který aplikace Microsoft Office Excel používá k zašifrování hesla sešitu.

Obor názvů:  Microsoft.Office.Tools.Excel
Sestavení:  Microsoft.Office.Tools.Excel.v4.0.Utilities (v Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntaxe

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

Hodnota vlastnosti

Typ: System.String
Algoritmus, který používá k šifrování hesel pro sešit aplikace Excel.

Poznámky

Použití SetPasswordEncryptionOptions metoda k určení, zda je aplikace Excel zašifruje vlastnosti souboru pro sešity chráněné heslem.

Příklady

Následující příklad kódu zkontroluje hodnotu vlastnosti HasPassword a určí, zda je sešit chráněn heslem.Pokud sešit není chráněný heslem, příklad nastaví vlastnost Password na heslo získané ze vstupu uživatele a voláním metody SetPasswordEncryptionOptions nastaví šifrovací algoritmus, délku klíče a jméno poskytovatele šifrování a povolí šifrování vlastností souboru.Následně příklad zobrazí hodnoty vlastností PasswordEncryptionProvider, PasswordEncryptionAlgorithm, PasswordEncryptionKeyLength a PasswordEncryptionFileProperties v listu Sheet1.Tento příklad předpokládá, že metoda GetPasswordFromUserInput je definována jinde.

Tento příklad je pro přizpůsobení na úrovni dokumentu.

Private Sub WorkbookPasswordOptions()
    If Not Me.HasPassword Then
        Me.Password = GetPasswordFromUserInput()
        Me.SetPasswordEncryptionOptions( _
            "Microsoft RSA SChannel Cryptographic Provider", _
            "RC4", 128, True)
    End If

    ' Display the password properties in Sheet1.
    Globals.Sheet1.Range("A1").Value2 = _
        "Password Encryption Provider:"
    Globals.Sheet1.Range("A2").Value2 = _
        "Password Encryption Algorithm:"
    Globals.Sheet1.Range("A3").Value2 = _
        "Password Encryption Key Length:"
    Globals.Sheet1.Range("A4").Value2 = _
        "Password Encryption File Properties:"
    Globals.Sheet1.Range("A1", "A4").Columns.AutoFit()

    Globals.Sheet1.Range("B1").Value2 = _
        Me.PasswordEncryptionProvider
    Globals.Sheet1.Range("B2").Value2 = _
        Me.PasswordEncryptionAlgorithm
    Globals.Sheet1.Range("B3").Value2 = _
        Me.PasswordEncryptionKeyLength
    Globals.Sheet1.Range("B4").Value2 = _
        Me.PasswordEncryptionFileProperties
    Globals.Sheet1.Range("B1", "B4").Columns.AutoFit()
End Sub
private void WorkbookPasswordOptions()
{
    if (!this.HasPassword)
    {
        this.Password = GetPasswordFromUserInput();
        this.SetPasswordEncryptionOptions(
            "Microsoft RSA SChannel Cryptographic Provider",
            "RC4", 128, true);
    }

    // Display the password properties in Sheet1.
    Globals.Sheet1.Range["A1"].Value2 =
        "Password Encryption Provider:";
    Globals.Sheet1.Range["A2"].Value2 =
        "Password Encryption Algorithm:";
    Globals.Sheet1.Range["A3"].Value2 =
        "Password Encryption Key Length:";
    Globals.Sheet1.Range["A4"].Value2 =
        "Password Encryption File Properties:";
    Globals.Sheet1.Range["A1", "A4"].Columns.AutoFit();

    Globals.Sheet1.Range["B1"].Value2 =
        this.PasswordEncryptionProvider;
    Globals.Sheet1.Range["B2"].Value2 =
        this.PasswordEncryptionAlgorithm;
    Globals.Sheet1.Range["B3"].Value2 =
        this.PasswordEncryptionKeyLength;
    Globals.Sheet1.Range["B4"].Value2 =
        this.PasswordEncryptionFileProperties;
    Globals.Sheet1.Range["B1", "B4"].Columns.AutoFit();
}

Zabezpečení rozhraní .NET Framework

Viz také

Referenční dokumentace

WorkbookBase Třída

Microsoft.Office.Tools.Excel – obor názvů