RIPEMD160Managed コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > RIPEMD160Managed コンストラクタの意味・解説 

RIPEMD160Managed コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

RIPEMD160 クラス新しインスタンス初期化します。

名前空間: System.Security.Cryptography
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim instance As New RIPEMD160Managed
public RIPEMD160Managed ()
public:
RIPEMD160Managed ()
public RIPEMD160Managed ()
public function RIPEMD160Managed ()
解説解説
使用例使用例

ディレクトリ内のすべてのファイルについて、RIPEMD160Managed クラスハッシュ計算する方法次のコード例示します

using System;
using System.IO;
using System.Security.Cryptography;

    public class HashDirectory
    {
        // 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();
        }

        public static void
 Main(String[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Usage: hashdir <directory>");
                return;
            }
            try
            {
                // Create a DirectoryInfo object representing the specified
 directory.
                DirectoryInfo dir = new DirectoryInfo(args[0]);
                // 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);
                    // 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.");
            }
        }
    }
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." );
   }

}

import System.*;
import System.IO.*;
import System.Security.Cryptography.*;

public class HashDirectory
{
    // Print the byte array in a readable format.
    public static void PrintByteArray(ubyte
 array[])
    {
        int i;
        for (i = 0; i < array.get_Length(); i++) {
            Console.Write(String.Format("{0:X2}", array.get_Item(i)));
            if (i % 4 == 3) {
                Console.Write(" ");
            }
        }
        Console.WriteLine();
    } //PrintByteArray

    public static void main(String[]
 args)
    {        
        if (args.get_Length() < 1) {
            Console.WriteLine("Usage: hashdir <directory>");
            return;
        }
        try {
            // Create a DirectoryInfo object representing the specified
 
            // directory.
            DirectoryInfo dir = new DirectoryInfo(args[0]);
            // Get the FileInfo objects for every file in the directory.
            FileInfo files[] = dir.GetFiles();
            // Initialize a RIPE160 hash object.
            RIPEMD160 myRIPEMD160 = RIPEMD160Managed.Create();
            ubyte hashValue[];
            FileInfo fInfo = null;
            for (int iCtr = 0; iCtr < files.get_Length();
 iCtr++) {
                // Compute and print the hash values for each file in
 directory.
                fInfo = files[iCtr];
                // 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(fInfo.get_Name() + ": ");
                // Write the hash value to the Console.
                PrintByteArray(hashValue);
                // Close the file.
                fileStream.Close();
            }
            return;
        }
        catch (DirectoryNotFoundException exp) {
            Console.WriteLine("Error: The directory specified could"
                + "not be found.");
        }
        catch (IOException exp) {
            Console.WriteLine("Error: A file in the directory
 could not "
                + "be accessed.");
        }
    } //main
} //HashDirectory
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「RIPEMD160Managed コンストラクタ」の関連用語

RIPEMD160Managed コンストラクタのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



RIPEMD160Managed コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS