SecureString 클래스

정의

더 이상 필요 없게 되면 컴퓨터 메모리에서 삭제되는 텍스트처럼 기밀을 유지해야 하는 텍스트를 나타냅니다. 이 클래스는 상속될 수 없습니다.

public ref class SecureString sealed : IDisposable
public sealed class SecureString : IDisposable
type SecureString = class
    interface IDisposable
Public NotInheritable Class SecureString
Implements IDisposable
상속
SecureString
구현

예제

다음 예제에서는 사용 하는 방법을 보여 줍니다.는 SecureString 새 프로세스를 시작 하는 자격 증명으로 사용 하기 위해 사용자의 암호를 보호 합니다.

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Security;

public class Example
{
    public static void Main()
    {
        // Instantiate the secure string.
        SecureString securePwd = new SecureString();
        ConsoleKeyInfo key;

        Console.Write("Enter password: ");
        do {
           key = Console.ReadKey(true);
           
           // Ignore any key out of range.
           if (((int) key.Key) >= 65 && ((int) key.Key <= 90)) {
              // Append the character to the password.
              securePwd.AppendChar(key.KeyChar);
              Console.Write("*");
           }   
        // Exit if Enter key is pressed.
        } while (key.Key != ConsoleKey.Enter);
        Console.WriteLine();
        
        try {
            Process.Start("Notepad.exe", "MyUser", securePwd, "MYDOMAIN");
        }
        catch (Win32Exception e) {
            Console.WriteLine(e.Message);
        }
        finally {
           securePwd.Dispose();
        }
    }
}
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Security

Public Class Example
    Public Shared Sub Main()
        ' Instantiate the secure string.
        Dim securePwd As New SecureString()
        Dim key As ConsoleKeyInfo
        
        Console.Write("Enter password: ")
        Do
           key = Console.ReadKey(True)

           ' Ignore any key out of range
           If CInt(key.Key) >= 65 And CInt(key.Key <= 90) Then    
              ' Append the character to the password.
              securePwd.AppendChar(key.KeyChar)
              Console.Write("*")
           End If                                    
        ' Exit if Enter key is pressed.
        Loop While key.Key <> ConsoleKey.Enter
        Console.WriteLine()
        
        Try
            Process.Start("Notepad.exe", "MyUser", securePwd, "MYDOMAIN")
        Catch e As Win32Exception
            Console.WriteLine(e.Message)
        Finally
           securePwd.Dispose()
        End Try
    End Sub
End Class

설명

이 API에 대한 자세한 내용은 SecureString에 대한 추가 API 설명을 참조하세요.

생성자

SecureString()

SecureString 클래스의 새 인스턴스를 초기화합니다.

SecureString(Char*, Int32)

Char 개체의 하위 배열에서 SecureString 클래스의 새 인스턴스를 초기화합니다.

이 생성자는 CLS 규격이 아닙니다. CLS 규격 대체 항목은 SecureString()입니다.

속성

Length

현재 보안 문자열의 문자 수를 가져옵니다.

메서드

AppendChar(Char)

현재 보안 문자열의 끝에 문자를 추가합니다.

Clear()

현재 보안 문자열의 값을 삭제합니다.

Copy()

현재 보안 문자열의 복사본을 만듭니다.

Dispose()

현재 SecureString 개체에서 사용하는 모든 리소스를 해제합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
InsertAt(Int32, Char)

이 보안 문자열의 지정한 인덱스 위치에 문자를 삽입합니다.

IsReadOnly()

이 보안 문자열이 읽기 전용으로 표시되었는지를 나타냅니다.

MakeReadOnly()

이 보안 문자열의 텍스트 값을 읽기 전용으로 만듭니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
RemoveAt(Int32)

이 보안 문자열에서 지정한 인덱스 위치의 문자를 제거합니다.

SetAt(Int32, Char)

지정한 인덱스 위치의 기존 문자를 다른 문자로 바꿉니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보