SecureString 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
더 이상 필요하지 않은 경우 컴퓨터 메모리에서 삭제하는 것과 같이 기밀로 유지해야 하는 텍스트를 나타냅니다. 이 클래스는 상속할 수 없습니다.
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 비고를 참조하세요.
생성자
| Name | Description |
|---|---|
| SecureString() |
SecureString 클래스의 새 인스턴스를 초기화합니다. |
| SecureString(Char*, Int32) |
개체의 하위 배열에서 클래스의 SecureString 새 인스턴스를 Char 초기화합니다. 이 생성자는 CLS 규격이 아닙니다. CLS 규격 대안은 .입니다 SecureString(). |
속성
| Name | Description |
|---|---|
| Length |
현재 보안 문자열의 문자 수를 가져옵니다. |
메서드
| Name | Description |
|---|---|
| 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) |