Share via


DESCryptoServiceProvider 클래스

정의

주의

Derived cryptographic types are obsolete. Use the Create method on the base type instead.

래퍼 개체를 정의하여 데이터 암호화 표준(DES) 알고리즘의 CSP(암호화 서비스 공급자) 버전에 액세스합니다. 이 클래스는 상속될 수 없습니다.

public ref class DESCryptoServiceProvider sealed : System::Security::Cryptography::DES
public sealed class DESCryptoServiceProvider : System.Security.Cryptography.DES
[System.Obsolete("Derived cryptographic types are obsolete. Use the Create method on the base type instead.", DiagnosticId="SYSLIB0021", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public sealed class DESCryptoServiceProvider : System.Security.Cryptography.DES
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class DESCryptoServiceProvider : System.Security.Cryptography.DES
type DESCryptoServiceProvider = class
    inherit DES
[<System.Obsolete("Derived cryptographic types are obsolete. Use the Create method on the base type instead.", DiagnosticId="SYSLIB0021", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type DESCryptoServiceProvider = class
    inherit DES
[<System.Runtime.InteropServices.ComVisible(true)>]
type DESCryptoServiceProvider = class
    inherit DES
Public NotInheritable Class DESCryptoServiceProvider
Inherits DES
상속
DESCryptoServiceProvider
특성

예제

다음 코드 예제에서는 지정된 키()와 초기화 벡터IV()를 사용하여 (KeyDES구현)을 사용하여 DESCryptoServiceProviderinName지정된 파일을 암호화합니다. 그런 다음, 에서 지정한 파일에 암호화된 outName결과를 출력합니다.

void EncryptData( String^ inName, String^ outName, array<Byte>^desKey, array<Byte>^desIV )
{
   
   //Create the file streams to handle the input and output files.
   FileStream^ fin = gcnew FileStream( inName,FileMode::Open,FileAccess::Read );
   FileStream^ fout = gcnew FileStream( outName,FileMode::OpenOrCreate,FileAccess::Write );
   fout->SetLength( 0 );
   
   //Create variables to help with read and write.
   array<Byte>^bin = gcnew array<Byte>(100);
   long rdlen = 0; //This is the total number of bytes written.

   long totlen = (long)fin->Length; //This is the total length of the input file.

   int len; //This is the number of bytes to be written at a time.

   DES^ des = gcnew DESCryptoServiceProvider;
   CryptoStream^ encStream = gcnew CryptoStream( fout,des->CreateEncryptor( desKey, desIV ),CryptoStreamMode::Write );
   Console::WriteLine( "Encrypting..." );
   
   //Read from the input file, then encrypt and write to the output file.
   while ( rdlen < totlen )
   {
      len = fin->Read( bin, 0, 100 );
      encStream->Write( bin, 0, len );
      rdlen = rdlen + len;
      Console::WriteLine( "{0} bytes processed", rdlen );
   }

   encStream->Close();
   fout->Close();
   fin->Close();
}
private static void EncryptData(string inName, string outName, byte[] desKey, byte[] desIV)
 {
     //Create the file streams to handle the input and output files.
     FileStream fin = new FileStream(inName, FileMode.Open, FileAccess.Read);
     FileStream fout = new FileStream(outName, FileMode.OpenOrCreate, FileAccess.Write);
     fout.SetLength(0);

     //Create variables to help with read and write.
     byte[] bin = new byte[100]; //This is intermediate storage for the encryption.
     long rdlen = 0;              //This is the total number of bytes written.
     long totlen = fin.Length;    //This is the total length of the input file.
     int len;                     //This is the number of bytes to be written at a time.

     DES des = new DESCryptoServiceProvider();
     CryptoStream encStream = new CryptoStream(fout, des.CreateEncryptor(desKey, desIV), CryptoStreamMode.Write);

     Console.WriteLine("Encrypting...");

     //Read from the input file, then encrypt and write to the output file.
     while(rdlen < totlen)
     {
         len = fin.Read(bin, 0, 100);
         encStream.Write(bin, 0, len);
         rdlen = rdlen + len;
         Console.WriteLine("{0} bytes processed", rdlen);
     }

     encStream.Close();
     fout.Close();
     fin.Close();
 }
Private Shared Sub EncryptData(inName As String, outName As String, _
desKey() As Byte, desIV() As Byte)

    'Create the file streams to handle the input and output files.
    Dim fin As New FileStream(inName, FileMode.Open, FileAccess.Read)
    Dim fout As New FileStream(outName, FileMode.OpenOrCreate, _
       FileAccess.Write)
    fout.SetLength(0)
    
    'Create variables to help with read and write.
    Dim bin(4096) As Byte 'This is intermediate storage for the encryption.
    Dim rdlen As Long = 0 'This is the total number of bytes written.
    Dim totlen As Long = fin.Length 'Total length of the input file.
    Dim len As Integer 'This is the number of bytes to be written at a time.
    Dim des As New DESCryptoServiceProvider()
    Dim encStream As New CryptoStream(fout, _
       des.CreateEncryptor(desKey, desIV), CryptoStreamMode.Write)
    
    Console.WriteLine("Encrypting...")
    
    'Read from the input file, then encrypt and write to the output file.
    While rdlen < totlen
        len = fin.Read(bin, 0, 4096)
        encStream.Write(bin, 0, len)
        rdlen = Convert.ToInt32(rdlen + len / des.BlockSize * des.BlockSize)
        Console.WriteLine("Processed {0} bytes, {1} bytes total", len, _
           rdlen)
    End While
    
    encStream.Close()
End Sub

암호 해독은 동일한 방식으로 처리할 수 있습니다. 대신 를 CreateEncryptor사용합니다CreateDecryptor. 파일을 암호화하는 데 사용되는 동일한 키(Key) 및 초기화 벡터(IV)를 사용하여 암호를 해독해야 합니다.

설명

이 알고리즘은 64비트 키 길이를 지원합니다.

중요

최신 대칭 암호화 알고리즘인 AES(Advanced Encryption Standard)를 사용할 수 있습니다. 클래스 대신 클래스를 Aes 사용하는 것이 좋습니다 DES . 사용 하 여 DES 레거시 애플리케이션 및 데이터를 사용 하 여 호환성을 위해서만 합니다.

생성자

DESCryptoServiceProvider()
사용되지 않음.

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

필드

BlockSizeValue
사용되지 않음.

암호화 작업의 블록 크기(비트)를 나타냅니다.

(다음에서 상속됨 SymmetricAlgorithm)
FeedbackSizeValue
사용되지 않음.

암호화 작업의 피드백 크기(비트 단위)를 나타냅니다.

(다음에서 상속됨 SymmetricAlgorithm)
IVValue
사용되지 않음.

대칭 알고리즘에 대한 초기화 벡터(IV)를 나타냅니다.

(다음에서 상속됨 SymmetricAlgorithm)
KeySizeValue
사용되지 않음.

대칭 알고리즘에서 사용하는 비밀 키의 크기(비트 단위)를 나타냅니다.

(다음에서 상속됨 SymmetricAlgorithm)
KeyValue
사용되지 않음.

대칭 알고리즘에 대한 비밀 키를 나타냅니다.

(다음에서 상속됨 SymmetricAlgorithm)
LegalBlockSizesValue
사용되지 않음.

대칭 알고리즘에서 지원하는 블록 크기(비트 단위)를 지정합니다.

(다음에서 상속됨 SymmetricAlgorithm)
LegalKeySizesValue
사용되지 않음.

대칭 알고리즘에서 지원하는 키 크기(비트 단위)를 지정합니다.

(다음에서 상속됨 SymmetricAlgorithm)
ModeValue
사용되지 않음.

대칭 알고리즘에 사용된 암호화 모드를 나타냅니다.

(다음에서 상속됨 SymmetricAlgorithm)
PaddingValue
사용되지 않음.

대칭 알고리즘에 사용된 패딩 모드를 나타냅니다.

(다음에서 상속됨 SymmetricAlgorithm)

속성

BlockSize
사용되지 않음.

암호화 작업의 블록 크기(비트 단위)를 가져오거나 설정합니다.

(다음에서 상속됨 SymmetricAlgorithm)
FeedbackSize
사용되지 않음.

CFB(Cipher Feedback) 및 OFB(Output Feedback) 암호화 모드에 대한 암호화 작업의 피드백 크기(비트 단위)를 가져오거나 설정합니다.

(다음에서 상속됨 SymmetricAlgorithm)
IV
사용되지 않음.

대칭 알고리즘에 대한 초기화 벡터(IV)를 가져오거나 설정합니다.

(다음에서 상속됨 SymmetricAlgorithm)
Key
사용되지 않음.

DES(데이터 암호화 표준) 알고리즘에 대한 비밀 키를 가져오거나 설정합니다.

(다음에서 상속됨 DES)
KeySize
사용되지 않음.

대칭 알고리즘에서 사용하는 비밀 키의 크기(비트 단위)를 가져오거나 설정합니다.

(다음에서 상속됨 SymmetricAlgorithm)
LegalBlockSizes
사용되지 않음.

대칭 알고리즘에서 지원하는 블록 크기(비트 단위)를 가져옵니다.

(다음에서 상속됨 SymmetricAlgorithm)
LegalKeySizes
사용되지 않음.

대칭 알고리즘에서 지원하는 키 크기(비트 단위)를 가져옵니다.

(다음에서 상속됨 SymmetricAlgorithm)
Mode
사용되지 않음.

대칭 알고리즘의 작업 모드를 가져오거나 설정합니다.

(다음에서 상속됨 SymmetricAlgorithm)
Padding
사용되지 않음.

대칭 알고리즘에 사용된 패딩 모드를 가져오거나 설정합니다.

(다음에서 상속됨 SymmetricAlgorithm)

메서드

Clear()
사용되지 않음.

SymmetricAlgorithm 클래스에서 사용하는 모든 리소스를 해제합니다.

(다음에서 상속됨 SymmetricAlgorithm)
CreateDecryptor()
사용되지 않음.

현재 Key 속성 및 초기화 벡터(IV)를 사용하여 대칭 decryptor 개체를 만듭니다.

CreateDecryptor()
사용되지 않음.

현재 Key 속성 및 초기화 벡터(IV)를 사용하여 대칭 decryptor 개체를 만듭니다.

(다음에서 상속됨 SymmetricAlgorithm)
CreateDecryptor(Byte[], Byte[])
사용되지 않음.

지정된 키(DES)와 초기화 벡터(Key)를 사용하여 대칭 데이터 암호화 표준(IV) decryptor 개체를 만듭니다.

CreateEncryptor()
사용되지 않음.

현재 Key 속성 및 초기화 벡터(IV)를 사용하여 대칭 encryptor 개체를 만듭니다.

CreateEncryptor()
사용되지 않음.

현재 Key 속성 및 초기화 벡터(IV)를 사용하여 대칭 encryptor 개체를 만듭니다.

(다음에서 상속됨 SymmetricAlgorithm)
CreateEncryptor(Byte[], Byte[])
사용되지 않음.

지정된 키(DES)와 초기화 벡터(Key)를 사용하여 대칭 데이터 암호화 표준(IV) encryptor 개체를 만듭니다.

DecryptCbc(Byte[], Byte[], PaddingMode)
사용되지 않음.

지정된 안쪽 여백 모드로 CBC 모드를 사용하여 데이터의 암호를 해독합니다.

(다음에서 상속됨 SymmetricAlgorithm)
DecryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode)
사용되지 않음.

지정된 안쪽 여백 모드로 CBC 모드를 사용하여 데이터의 암호를 해독합니다.

(다음에서 상속됨 SymmetricAlgorithm)
DecryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)
사용되지 않음.

지정된 패딩 모드가 있는 CBC 모드를 사용하여 데이터를 지정된 버퍼로 해독합니다.

(다음에서 상속됨 SymmetricAlgorithm)
DecryptCfb(Byte[], Byte[], PaddingMode, Int32)
사용되지 않음.

지정된 안쪽 여백 모드 및 피드백 크기가 있는 CFB 모드를 사용하여 데이터의 암호를 해독합니다.

(다음에서 상속됨 SymmetricAlgorithm)
DecryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode, Int32)
사용되지 않음.

지정된 안쪽 여백 모드 및 피드백 크기가 있는 CFB 모드를 사용하여 데이터의 암호를 해독합니다.

(다음에서 상속됨 SymmetricAlgorithm)
DecryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)
사용되지 않음.

지정된 패딩 모드 및 피드백 크기가 있는 CFB 모드를 사용하여 데이터를 지정된 버퍼로 해독합니다.

(다음에서 상속됨 SymmetricAlgorithm)
DecryptEcb(Byte[], PaddingMode)
사용되지 않음.

지정된 안쪽 여백 모드로 ECB 모드를 사용하여 데이터의 암호를 해독합니다.

(다음에서 상속됨 SymmetricAlgorithm)
DecryptEcb(ReadOnlySpan<Byte>, PaddingMode)
사용되지 않음.

지정된 안쪽 여백 모드로 ECB 모드를 사용하여 데이터의 암호를 해독합니다.

(다음에서 상속됨 SymmetricAlgorithm)
DecryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)
사용되지 않음.

지정된 패딩 모드에서 ECB 모드를 사용하여 데이터를 지정된 버퍼로 해독합니다.

(다음에서 상속됨 SymmetricAlgorithm)
Dispose()
사용되지 않음.

SymmetricAlgorithm 클래스의 현재 인스턴스에서 사용하는 모든 리소스를 해제합니다.

(다음에서 상속됨 SymmetricAlgorithm)
Dispose(Boolean)
사용되지 않음.

SymmetricAlgorithm에서 사용하는 관리되지 않는 리소스를 해제하고, 관리되는 리소스를 선택적으로 해제할 수 있습니다.

(다음에서 상속됨 SymmetricAlgorithm)
EncryptCbc(Byte[], Byte[], PaddingMode)
사용되지 않음.

지정된 안쪽 여백 모드로 CBC 모드를 사용하여 데이터를 암호화합니다.

(다음에서 상속됨 SymmetricAlgorithm)
EncryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode)
사용되지 않음.

지정된 안쪽 여백 모드로 CBC 모드를 사용하여 데이터를 암호화합니다.

(다음에서 상속됨 SymmetricAlgorithm)
EncryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)
사용되지 않음.

지정된 패딩 모드가 있는 CBC 모드를 사용하여 데이터를 지정된 버퍼로 암호화합니다.

(다음에서 상속됨 SymmetricAlgorithm)
EncryptCfb(Byte[], Byte[], PaddingMode, Int32)
사용되지 않음.

지정된 안쪽 여백 모드 및 피드백 크기로 CFB 모드를 사용하여 데이터를 암호화합니다.

(다음에서 상속됨 SymmetricAlgorithm)
EncryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode, Int32)
사용되지 않음.

지정된 안쪽 여백 모드 및 피드백 크기로 CFB 모드를 사용하여 데이터를 암호화합니다.

(다음에서 상속됨 SymmetricAlgorithm)
EncryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)
사용되지 않음.

지정된 패딩 모드 및 피드백 크기가 있는 CFB 모드를 사용하여 데이터를 지정된 버퍼로 암호화합니다.

(다음에서 상속됨 SymmetricAlgorithm)
EncryptEcb(Byte[], PaddingMode)
사용되지 않음.

지정된 안쪽 여백 모드로 ECB 모드를 사용하여 데이터를 암호화합니다.

(다음에서 상속됨 SymmetricAlgorithm)
EncryptEcb(ReadOnlySpan<Byte>, PaddingMode)
사용되지 않음.

지정된 안쪽 여백 모드로 ECB 모드를 사용하여 데이터를 암호화합니다.

(다음에서 상속됨 SymmetricAlgorithm)
EncryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)
사용되지 않음.

지정된 패딩 모드에서 ECB 모드를 사용하여 데이터를 지정된 버퍼로 암호화합니다.

(다음에서 상속됨 SymmetricAlgorithm)
Equals(Object)
사용되지 않음.

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

(다음에서 상속됨 Object)
GenerateIV()
사용되지 않음.

알고리즘에 사용할 임의의 초기화 벡터(IV)를 생성합니다.

GenerateKey()
사용되지 않음.

알고리즘에 사용할 임의의 키(Key)를 생성합니다.

GetCiphertextLengthCbc(Int32, PaddingMode)
사용되지 않음.

CBC 모드에서 지정된 안쪽 여백 모드 및 일반 텍스트 길이가 있는 암호 텍스트의 길이를 가져옵니다.

(다음에서 상속됨 SymmetricAlgorithm)
GetCiphertextLengthCfb(Int32, PaddingMode, Int32)
사용되지 않음.

CFB 모드에서 지정된 안쪽 여백 모드 및 일반 텍스트 길이가 있는 암호 텍스트의 길이를 가져옵니다.

(다음에서 상속됨 SymmetricAlgorithm)
GetCiphertextLengthEcb(Int32, PaddingMode)
사용되지 않음.

ECB 모드에서 지정된 안쪽 여백 모드 및 일반 텍스트 길이가 있는 암호 텍스트의 길이를 가져옵니다.

(다음에서 상속됨 SymmetricAlgorithm)
GetHashCode()
사용되지 않음.

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

(다음에서 상속됨 Object)
GetType()
사용되지 않음.

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

(다음에서 상속됨 Object)
MemberwiseClone()
사용되지 않음.

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

(다음에서 상속됨 Object)
ToString()
사용되지 않음.

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

(다음에서 상속됨 Object)
TryDecryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Int32, PaddingMode)
사용되지 않음.

지정된 패딩 모드가 있는 CBC 모드를 사용하여 데이터를 지정된 버퍼로 해독하려고 시도합니다.

(다음에서 상속됨 SymmetricAlgorithm)
TryDecryptCbcCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)
사용되지 않음.

파생 클래스에서 재정의된 경우 지정된 패딩 모드가 있는 CBC 모드를 사용하여 데이터를 지정된 버퍼로 해독하려고 시도합니다.

(다음에서 상속됨 SymmetricAlgorithm)
TryDecryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Int32, PaddingMode, Int32)
사용되지 않음.

지정된 패딩 모드 및 피드백 크기가 있는 CFB 모드를 사용하여 데이터를 지정된 버퍼로 해독하려고 시도합니다.

(다음에서 상속됨 SymmetricAlgorithm)
TryDecryptCfbCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32, Int32)
사용되지 않음.

파생 클래스에서 재정의된 경우 지정된 패딩 모드 및 피드백 크기와 함께 CFB 모드를 사용하여 데이터를 지정된 버퍼로 해독하려고 시도합니다.

(다음에서 상속됨 SymmetricAlgorithm)
TryDecryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)
사용되지 않음.

지정된 패딩 모드에서 ECB 모드를 사용하여 데이터를 지정된 버퍼로 해독하려고 시도합니다.

(다음에서 상속됨 SymmetricAlgorithm)
TryDecryptEcbCore(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)
사용되지 않음.

파생 클래스에서 재정의된 경우 지정된 패딩 모드에서 ECB 모드를 사용하여 데이터를 지정된 버퍼로 해독하려고 시도합니다.

(다음에서 상속됨 SymmetricAlgorithm)
TryEncryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Int32, PaddingMode)
사용되지 않음.

지정된 패딩 모드가 있는 CBC 모드를 사용하여 데이터를 지정된 버퍼로 암호화하려고 시도합니다.

(다음에서 상속됨 SymmetricAlgorithm)
TryEncryptCbcCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)
사용되지 않음.

파생 클래스에서 재정의된 경우 지정된 패딩 모드가 있는 CBC 모드를 사용하여 데이터를 지정된 버퍼로 암호화하려고 시도합니다.

(다음에서 상속됨 SymmetricAlgorithm)
TryEncryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Int32, PaddingMode, Int32)
사용되지 않음.

지정된 패딩 모드 및 피드백 크기가 있는 CFB 모드를 사용하여 데이터를 지정된 버퍼로 암호화하려고 시도합니다.

(다음에서 상속됨 SymmetricAlgorithm)
TryEncryptCfbCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32, Int32)
사용되지 않음.

파생 클래스에서 재정의된 경우 지정된 패딩 모드 및 피드백 크기와 함께 CFB 모드를 사용하여 데이터를 지정된 버퍼로 암호화하려고 시도합니다.

(다음에서 상속됨 SymmetricAlgorithm)
TryEncryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)
사용되지 않음.

지정된 패딩 모드에서 ECB 모드를 사용하여 데이터를 지정된 버퍼로 암호화하려고 시도합니다.

(다음에서 상속됨 SymmetricAlgorithm)
TryEncryptEcbCore(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)
사용되지 않음.

파생 클래스에서 재정의된 경우 지정된 패딩 모드에서 ECB 모드를 사용하여 데이터를 지정된 버퍼로 암호화하려고 시도합니다.

(다음에서 상속됨 SymmetricAlgorithm)
ValidKeySize(Int32)
사용되지 않음.

지정된 키 크기를 현재 알고리즘에 사용할 수 있는지 여부를 결정합니다.

(다음에서 상속됨 SymmetricAlgorithm)

명시적 인터페이스 구현

IDisposable.Dispose()

이 API는 제품 인프라를 지원하며 코드에서 직접 사용되지 않습니다.

사용되지 않음.

SymmetricAlgorithm에서 사용하는 관리되지 않는 리소스를 해제하고, 관리되는 리소스를 선택적으로 해제할 수 있습니다.

(다음에서 상속됨 SymmetricAlgorithm)

적용 대상

추가 정보