Share via


WorkbookBase.SetPasswordEncryptionOptions 메서드

암호를 사용하여 통합 문서를 암호화하기 위한 옵션을 설정합니다.

네임스페이스:  Microsoft.Office.Tools.Excel
어셈블리:  Microsoft.Office.Tools.Excel.v4.0.Utilities(Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

구문

‘선언
Public Sub SetPasswordEncryptionOptions ( _
    passwordEncryptionProvider As Object, _
    passwordEncryptionAlgorithm As Object, _
    passwordEncryptionKeyLength As Object, _
    passwordEncryptionFileProperties As Object _
)
public void SetPasswordEncryptionOptions(
    Object passwordEncryptionProvider,
    Object passwordEncryptionAlgorithm,
    Object passwordEncryptionKeyLength,
    Object passwordEncryptionFileProperties
)

매개 변수

  • passwordEncryptionProvider
    형식: System.Object
    암호화 공급자의 대/소문자 구분 문자열입니다.
  • passwordEncryptionAlgorithm
    형식: System.Object
    "RC4"와 같은 알고리즘 방식 약식 이름의 대/소문자 구분 문자열입니다.알고리즘 방식 약식 이름의 대/소문자 구분 문자열입니다.
  • passwordEncryptionKeyLength
    형식: System.Object
    암호화 키 길이로, 40보다 큰 8의 배수입니다.
  • passwordEncryptionFileProperties
    형식: System.Object
    파일 속성을 암호화하려면 true(기본값)입니다.

설명

PasswordEncryptionProvider, PasswordEncryptionAlgorithm 및 PasswordEncryptionKeyLength 매개 변수는 서로 종속적입니다. 선택한 암호화 공급자에 따라 선택할 수 있는 알고리즘 집합 및 키 길이가 제한됩니다.

PasswordEncryptionKeyLength 매개 변수의 경우에는 기본적으로 키 길이의 범위에 대한 제한이 없습니다. 이 범위도 암호화 알고리즘을 결정하는 암호화 서비스 공급자에 의해 결정됩니다.

선택적 매개 변수

선택적 매개 변수에 대한 자세한 내용은 Office 솔루션의 선택적 매개 변수를 참조하십시오.

예제

다음 코드 예제에서는 HasPassword 속성의 값을 검사하여 통합 문서가 암호로 보호되는지 여부를 확인합니다. 통합 문서가 암호로 보호되지 않으면 예제에서는 Password 속성을 사용자 입력에서 가져온 암호로 설정한 다음 SetPasswordEncryptionOptions 메서드를 호출하여 암호화 알고리즘, 키 길이 및 암호화 공급자의 이름을 설정하고 파일 속성 암호화를 사용합니다. 그런 다음 예제에서는 PasswordEncryptionProvider, PasswordEncryptionAlgorithm, PasswordEncryptionKeyLengthPasswordEncryptionFileProperties 속성의 값을 워크시트 Sheet1에 표시합니다. 이 예제에서는 GetPasswordFromUserInput 메서드가 다른 곳에 정의되어 있다고 가정합니다.

이 예제는 문서 수준 사용자 지정을 위한 것입니다.

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", missing].Value2 =
        "Password Encryption Provider:";
    Globals.Sheet1.Range["A2", missing].Value2 =
        "Password Encryption Algorithm:";
    Globals.Sheet1.Range["A3", missing].Value2 =
        "Password Encryption Key Length:";
    Globals.Sheet1.Range["A4", missing].Value2 =
        "Password Encryption File Properties:";
    Globals.Sheet1.Range["A1", "A4"].Columns.AutoFit();

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

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

WorkbookBase 클래스

Microsoft.Office.Tools.Excel 네임스페이스