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 비트 암호화 해시 함수입니다. MD4, MD5 및 RIPEMD 128 비트 해시 함수에 대 한 보안 대신 사용할 것입니다. RIPEMD는 RIPE (경합 무결성 기본 평가, 1988 1992) EU 프로젝트의 프레임 워크에서 개발 되었습니다.

참고

RIPEMD160Managed 파생된 클래스를 보안 해시 알고리즘 SHA-256 및 SHA-512로 대체 되었습니다. SHA256ManagedSHA512Managed 보다 더 나은 성능과 보안을 제공 RIPEMD160Managed합니다. 사용 하 여 RIPEMD160Managed 레거시 애플리케이션 및 데이터를 사용 하 여 호환성을 위해서만 합니다.

생성자

RIPEMD160Managed()

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

필드

HashSizeValue

계산된 해시 코드의 크기(비트)를 나타냅니다.

(다음에서 상속됨 HashAlgorithm)
HashValue

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

(다음에서 상속됨 HashAlgorithm)
State

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

(다음에서 상속됨 HashAlgorithm)

속성

CanReuseTransform

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

(다음에서 상속됨 HashAlgorithm)
CanTransformMultipleBlocks

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

(다음에서 상속됨 HashAlgorithm)
Hash

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

(다음에서 상속됨 HashAlgorithm)
HashSize

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

(다음에서 상속됨 HashAlgorithm)
InputBlockSize

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

(다음에서 상속됨 HashAlgorithm)
OutputBlockSize

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

(다음에서 상속됨 HashAlgorithm)

메서드

Clear()

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

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

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

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

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

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

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

(다음에서 상속됨 HashAlgorithm)
ComputeHashAsync(Stream, CancellationToken)

지정된 Stream 개체에 대해 비동기적으로 해시 값을 계산합니다.

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

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

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

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

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

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

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

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

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

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

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

파생 클래스에 재정의된 경우 개체에 쓰여진 데이터의 경로를 해시를 계산할 RIPEMD160 해시 알고리즘에 지정합니다.

HashCore(ReadOnlySpan<Byte>)

개체에 쓴 데이터를 해시를 계산하기 위한 해시 알고리즘으로 경로 처리합니다.

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

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

Initialize()

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

MemberwiseClone()

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

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

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

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

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

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

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

(다음에서 상속됨 HashAlgorithm)
TryComputeHash(ReadOnlySpan<Byte>, Span<Byte>, Int32)

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

(다음에서 상속됨 HashAlgorithm)
TryHashFinal(Span<Byte>, Int32)

해시 알고리즘에서 마지막 데이터를 처리한 후 해시 계산을 완료하려고 시도합니다.

(다음에서 상속됨 HashAlgorithm)

명시적 인터페이스 구현

IDisposable.Dispose()

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

(다음에서 상속됨 HashAlgorithm)

적용 대상

추가 정보