RIPEMD160Managed 클래스

정의

관리되는 라이브러리를 RIPEMD160 사용하여 입력 데이터에 대한 해시를 계산합니다.

public ref class RIPEMD160Managed : System::Security::Cryptography::RIPEMD160
[System.Runtime.InteropServices.ComVisible(true)]
public class RIPEMD160Managed : System.Security.Cryptography.RIPEMD160
[<System.Runtime.InteropServices.ComVisible(true)>]
type RIPEMD160Managed = class
    inherit RIPEMD160
Public Class RIPEMD160Managed
Inherits RIPEMD160
상속
RIPEMD160Managed
특성

예제

다음 코드 예제에서는 클래스를 사용하여 RIPEMD160Managed 파일을 인코딩한 다음 파일을 디코딩하는 방법을 보여줍니다.

using namespace System;
using namespace System::IO;
using namespace System::Security::Cryptography;

// Print the byte array in a readable format.
void PrintByteArray( array<Byte>^array )
{
   int i;
   for ( i = 0; i < array->Length; i++ )
   {
      Console::Write( String::Format( "{0:X2}", array[ i ] ) );
      if ( (i % 4) == 3 )
            Console::Write( " " );

   }
   Console::WriteLine();
}

int main()
{
   array<String^>^args = Environment::GetCommandLineArgs();
   if ( args->Length < 2 )
   {
      Console::WriteLine( "Usage: hashdir <directory>" );
      return 0;
   }

   try
   {
      
      // Create a DirectoryInfo object representing the specified directory.
      DirectoryInfo^ dir = gcnew DirectoryInfo( args[ 1 ] );
      
      // Get the FileInfo objects for every file in the directory.
      array<FileInfo^>^files = dir->GetFiles();
      
      // Initialize a RIPE160 hash object.
      RIPEMD160 ^ myRIPEMD160 = RIPEMD160Managed::Create();
      array<Byte>^hashValue;
      
      // Compute and print the hash values for each file in directory.
      System::Collections::IEnumerator^ myEnum = files->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         FileInfo^ fInfo = safe_cast<FileInfo^>(myEnum->Current);
         
         // Create a fileStream for the file.
         FileStream^ fileStream = fInfo->Open( FileMode::Open );
         
         // Compute the hash of the fileStream.
         hashValue = myRIPEMD160->ComputeHash( fileStream );
         
         // Write the name of the file to the Console.
         Console::Write( "{0}: ", fInfo->Name );
         
         // Write the hash value to the Console.
         PrintByteArray( hashValue );
         
         // Close the file.
         fileStream->Close();
      }
      return 0;
   }
   catch ( DirectoryNotFoundException^ ) 
   {
      Console::WriteLine( "Error: The directory specified could not be found." );
   }
   catch ( IOException^ ) 
   {
      Console::WriteLine( "Error: A file in the directory could not be accessed." );
   }

}
using System;
using System.IO;
using System.Security.Cryptography;
using System.Windows.Forms;

public class HashDirectory
{

    [STAThreadAttribute]
    public static void Main(String[] args)
    {
        string directory = "";
        if (args.Length < 1)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            DialogResult dr = fbd.ShowDialog();
            if (dr == DialogResult.OK)
            {
                directory = fbd.SelectedPath;
            }
            else
            {
                Console.WriteLine("No directory selected.");
                return;
            }
        }
        else
        {
            directory = args[0];
        }

        try
        {
            // Create a DirectoryInfo object representing the specified directory.
            DirectoryInfo dir = new DirectoryInfo(directory);
            // Get the FileInfo objects for every file in the directory.
            FileInfo[] files = dir.GetFiles();
            // Initialize a RIPE160 hash object.
            RIPEMD160 myRIPEMD160 = RIPEMD160Managed.Create();
            byte[] hashValue;
            // Compute and print the hash values for each file in directory.
            foreach (FileInfo fInfo in files)
            {
                // Create a fileStream for the file.
                FileStream fileStream = fInfo.Open(FileMode.Open);
                // Be sure it's positioned to the beginning of the stream.
                fileStream.Position = 0;
                // Compute the hash of the fileStream.
                hashValue = myRIPEMD160.ComputeHash(fileStream);
                // Write the name of the file to the Console.
                Console.Write(fInfo.Name + ": ");
                // Write the hash value to the Console.
                PrintByteArray(hashValue);
                // Close the file.
                fileStream.Close();
            }
            return;
        }
        catch (DirectoryNotFoundException)
        {
            Console.WriteLine("Error: The directory specified could not be found.");
        }
        catch (IOException)
        {
            Console.WriteLine("Error: A file in the directory could not be accessed.");
        }
    }
    // Print the byte array in a readable format.
    public static void PrintByteArray(byte[] array)
    {
        int i;
        for (i = 0; i < array.Length; i++)
        {
            Console.Write(String.Format("{0:X2}", array[i]));
            if ((i % 4) == 3) Console.Write(" ");
        }
        Console.WriteLine();
    }
}
Imports System.IO
Imports System.Security.Cryptography
Imports System.Windows.Forms

Public Class HashDirectory

    Public Shared Sub Main(ByVal args() As String)
        Dim directory As String
        If args.Length < 1 Then
            Dim fdb As New FolderBrowserDialog
            Dim dr As DialogResult = fdb.ShowDialog()
            If (dr = DialogResult.OK) Then
                directory = fdb.SelectedPath
            Else
                Console.WriteLine("No directory selected")
                Return
            End If
        Else
            directory = args(0)
        End If
        Try
            ' Create a DirectoryInfo object representing the specified directory.
            Dim dir As New DirectoryInfo(directory)
            ' Get the FileInfo objects for every file in the directory.
            Dim files As FileInfo() = dir.GetFiles()
            ' Initialize a RIPE160 hash object.
            Dim myRIPEMD160 As RIPEMD160 = RIPEMD160Managed.Create()
            Dim hashValue() As Byte
            ' Compute and print the hash values for each file in directory.
            Dim fInfo As FileInfo
            For Each fInfo In files
                ' Create a fileStream for the file.
                Dim fileStream As FileStream = fInfo.Open(FileMode.Open)
                ' Be sure it's positioned to the beginning of the stream.
                fileStream.Position = 0
                ' Compute the hash of the fileStream.
                hashValue = myRIPEMD160.ComputeHash(fileStream)
                ' Write the name of the file to the Console.
                Console.Write(fInfo.Name + ": ")
                ' Write the hash value to the Console.
                PrintByteArray(hashValue)
                ' Close the file.
                fileStream.Close()
            Next fInfo
            Return
        Catch DExc As DirectoryNotFoundException
            Console.WriteLine("Error: The directory specified could not be found.")
        Catch IOExc As IOException
            Console.WriteLine("Error: A file in the directory could not be accessed.")
        End Try

    End Sub

    ' Print the byte array in a readable format.
    Public Shared Sub PrintByteArray(ByVal array() As Byte)
        Dim i As Integer
        For i = 0 To array.Length - 1
            Console.Write(String.Format("{0:X2}", array(i)))
            If i Mod 4 = 3 Then
                Console.Write(" ")
            End If
        Next i
        Console.WriteLine()

    End Sub
End Class

설명

RIPEMD-160은 160비트 암호화 해시 함수입니다. 128비트 해시 함수 MD4, MD5 및 RIPEMD에 대한 보안 대체로 사용하기 위한 것입니다. RIPEMD는 EU 프로젝트 RIPE(RACE Integrity Primitives Evaluation, 1988-1992)의 프레임워크에서 개발되었습니다.

메모

RIPEMD160Managed 은 보안 해시 알고리즘 SHA-256 및 SHA-512 및 해당 파생 클래스로 대체되었습니다. SHA256Managed 보다 SHA512Managed 더 나은 보안 및 성능을 RIPEMD160Managed제공합니다. 레거시 애플리케이션 및 데이터와의 호환성에만 사용합니다 RIPEMD160Managed .

생성자

Name Description
RIPEMD160Managed()

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

필드

Name Description
HashSizeValue

계산된 해시 코드의 크기를 비트 단위로 나타냅니다.

(다음에서 상속됨 HashAlgorithm)
HashValue

계산된 해시 코드의 값을 나타냅니다.

(다음에서 상속됨 HashAlgorithm)
State

해시 계산의 상태를 나타냅니다.

(다음에서 상속됨 HashAlgorithm)

속성

Name Description
CanReuseTransform

현재 변환을 다시 사용할 수 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 HashAlgorithm)
CanTransformMultipleBlocks

파생 클래스에서 재정의되는 경우 여러 블록을 변환할 수 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 HashAlgorithm)
Hash

계산된 해시 코드의 값을 가져옵니다.

(다음에서 상속됨 HashAlgorithm)
HashSize

계산된 해시 코드의 크기를 비트 단위로 가져옵니다.

(다음에서 상속됨 HashAlgorithm)
InputBlockSize

파생 클래스에서 재정의되는 경우 입력 블록 크기를 가져옵니다.

(다음에서 상속됨 HashAlgorithm)
OutputBlockSize

파생 클래스에서 재정의되는 경우 출력 블록 크기를 가져옵니다.

(다음에서 상속됨 HashAlgorithm)

메서드

Name Description
Clear()

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

(다음에서 상속됨 HashAlgorithm)
ComputeHash(Byte[], Int32, Int32)

지정된 바이트 배열의 지정된 영역에 대한 해시 값을 계산합니다.

(다음에서 상속됨 HashAlgorithm)
ComputeHash(Byte[])

지정된 바이트 배열의 해시 값을 계산합니다.

(다음에서 상속됨 HashAlgorithm)
ComputeHash(Stream)

지정된 Stream 개체의 해시 값을 계산합니다.

(다음에서 상속됨 HashAlgorithm)
Dispose()

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

(다음에서 상속됨 HashAlgorithm)
Dispose(Boolean)

관리되지 않는 리소스를 HashAlgorithm 해제하고 관리되는 리소스를 선택적으로 해제합니다.

(다음에서 상속됨 HashAlgorithm)
Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.

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

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

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

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

(다음에서 상속됨 Object)
HashCore(Byte[], Int32, Int32)

파생 클래스에서 재정의되는 경우 해시를 계산하기 위해 개체에 기록된 데이터를 해시 알고리즘으로 RIPEMD160 라우팅합니다.

HashFinal()

파생 클래스에서 재정의된 경우 암호화 스트림 개체에서 마지막 데이터를 처리한 후 해시 계산을 완료합니다.

Initialize()

관리되는 라이브러리를 사용하여 클래스의 RIPEMD160Managed 인스턴스를 초기화합니다.

MemberwiseClone()

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

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

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

(다음에서 상속됨 Object)
TransformBlock(Byte[], Int32, Int32, Byte[], Int32)

입력 바이트 배열의 지정된 영역에 대한 해시 값을 계산하고 입력 바이트 배열의 지정된 영역을 출력 바이트 배열의 지정된 영역에 복사합니다.

(다음에서 상속됨 HashAlgorithm)
TransformFinalBlock(Byte[], Int32, Int32)

지정된 바이트 배열의 지정된 영역에 대한 해시 값을 계산합니다.

(다음에서 상속됨 HashAlgorithm)

명시적 인터페이스 구현

Name Description
IDisposable.Dispose()

관리되지 않는 리소스를 HashAlgorithm 해제하고 관리되는 리소스를 선택적으로 해제합니다.

(다음에서 상속됨 HashAlgorithm)

적용 대상

추가 정보