RIPEMD160 クラス
アセンブリ: mscorlib (mscorlib.dll 内)


ハッシュ関数は、任意の長さのバイナリ文字列を固定長の小さなバイナリ文字列に割り当てます。暗号ハッシュ関数では、同じ値にハッシュされる 2 つの異なる入力値を検出することが計算上不可能です。つまり、2 組のデータのハッシュは、対応するデータも一致している場合にだけ一致します。データを少し変更しただけでも、ハッシュは予測できないほど大幅に変更されてしまいます。
RIPEMD-160 は、160 ビットの暗号ハッシュ関数です。128 ビットのハッシュ関数 MD4、MD5、および RIPEMD に代わるものです。RIPEMD は、EU プロジェクト RIPE (RACE Integrity Primitives Evaluation、1988 ~ 1992) の一環として開発されました。

ディレクトリ内のすべてのファイルについて、RIPEMD160 のハッシュを計算する方法を次のコード例に示します。
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

System.Security.Cryptography.HashAlgorithm
System.Security.Cryptography.RIPEMD160
System.Security.Cryptography.RIPEMD160Managed


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


RIPEMD160 コンストラクタ
アセンブリ: mscorlib (mscorlib.dll 内)


抽象クラスのインスタンスは作成できません。アプリケーション コードは、派生クラスの新しいインスタンスを作成します。詳細については、RIPEMD160Managed クラスのトピックを参照してください。

ディレクトリ内のすべてのファイルについて、RIPEMD160 ハッシュを計算する方法を次のコード例に示します。
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

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


RIPEMD160 フィールド

名前 | 説明 | |
---|---|---|
![]() | HashSizeValue | 計算されたハッシュ コードのサイズをビット単位で表します。 ( HashAlgorithm から継承されます。) |
![]() | HashValue | 計算されたハッシュ コードの値を表します。 ( HashAlgorithm から継承されます。) |
![]() | State | ハッシュ計算の状態を表します。 ( HashAlgorithm から継承されます。) |

RIPEMD160 プロパティ

名前 | 説明 | |
---|---|---|
![]() | CanReuseTransform | 現在の変換を再利用できるかどうかを示す値を取得します。 ( HashAlgorithm から継承されます。) |
![]() | CanTransformMultipleBlocks | 派生クラスでオーバーライドされると、複数のブロックを変換できるかどうかを示す値を取得します。 ( HashAlgorithm から継承されます。) |
![]() | Hash | 計算されたハッシュ コードの値を取得します。 ( HashAlgorithm から継承されます。) |
![]() | HashSize | 計算されたハッシュ コードのサイズをビット単位で取得します。 ( HashAlgorithm から継承されます。) |
![]() | InputBlockSize | 派生クラスでオーバーライドされると、入力ブロック サイズを取得します。 ( HashAlgorithm から継承されます。) |
![]() | OutputBlockSize | 派生クラスでオーバーライドされると、出力ブロック サイズを取得します。 ( HashAlgorithm から継承されます。) |

RIPEMD160 メソッド

名前 | 説明 | |
---|---|---|
![]() | Clear | HashAlgorithm クラスによって使用されているすべてのリソースを解放します。 ( HashAlgorithm から継承されます。) |
![]() | ComputeHash | オーバーロードされます。 入力データのハッシュ値を計算します。 ( HashAlgorithm から継承されます。) |
![]() | Create | オーバーロードされます。 RIPEMD160 クラスに固有の実装を作成します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | Initialize | HashAlgorithm クラスの実装を初期化します。 ( HashAlgorithm から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |
![]() | TransformBlock | 入力バイト配列の指定した領域のハッシュ値を計算し、結果ハッシュ値を出力バイト配列の指定した領域にコピーします。 ( HashAlgorithm から継承されます。) |
![]() | TransformFinalBlock | 指定したバイト配列の指定した領域のハッシュ値を計算します。 ( HashAlgorithm から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Dispose | HashAlgorithm によって使用されているアンマネージ リソースを解放し、オプションでマネージ リソースも解放します。 ( HashAlgorithm から継承されます。) |
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | HashCore | 派生クラスでオーバーライドされると、ハッシュを計算するために、オブジェクトに書き込まれたデータをハッシュ アルゴリズムにルーティングします。 ( HashAlgorithm から継承されます。) |
![]() | HashFinal | 派生クラスでオーバーライドされると、暗号ストリーム オブジェクトによって最後のデータが処理された後に、ハッシュ計算を終了します。 ( HashAlgorithm から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

RIPEMD160 メンバ
MD160 ハッシュ アルゴリズムのすべての実装が継承する、抽象クラスを表します。
RIPEMD160 データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | HashSizeValue | 計算されたハッシュ コードのサイズをビット単位で表します。(HashAlgorithm から継承されます。) |
![]() | HashValue | 計算されたハッシュ コードの値を表します。(HashAlgorithm から継承されます。) |
![]() | State | ハッシュ計算の状態を表します。(HashAlgorithm から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | CanReuseTransform | 現在の変換を再利用できるかどうかを示す値を取得します。(HashAlgorithm から継承されます。) |
![]() | CanTransformMultipleBlocks | 派生クラスでオーバーライドされると、複数のブロックを変換できるかどうかを示す値を取得します。(HashAlgorithm から継承されます。) |
![]() | Hash | 計算されたハッシュ コードの値を取得します。(HashAlgorithm から継承されます。) |
![]() | HashSize | 計算されたハッシュ コードのサイズをビット単位で取得します。(HashAlgorithm から継承されます。) |
![]() | InputBlockSize | 派生クラスでオーバーライドされると、入力ブロック サイズを取得します。(HashAlgorithm から継承されます。) |
![]() | OutputBlockSize | 派生クラスでオーバーライドされると、出力ブロック サイズを取得します。(HashAlgorithm から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Clear | HashAlgorithm クラスによって使用されているすべてのリソースを解放します。 (HashAlgorithm から継承されます。) |
![]() | ComputeHash | オーバーロードされます。 入力データのハッシュ値を計算します。 (HashAlgorithm から継承されます。) |
![]() | Create | オーバーロードされます。 RIPEMD160 クラスに固有の実装を作成します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | Initialize | HashAlgorithm クラスの実装を初期化します。 (HashAlgorithm から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |
![]() | TransformBlock | 入力バイト配列の指定した領域のハッシュ値を計算し、結果ハッシュ値を出力バイト配列の指定した領域にコピーします。 (HashAlgorithm から継承されます。) |
![]() | TransformFinalBlock | 指定したバイト配列の指定した領域のハッシュ値を計算します。 (HashAlgorithm から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Dispose | HashAlgorithm によって使用されているアンマネージ リソースを解放し、オプションでマネージ リソースも解放します。 (HashAlgorithm から継承されます。) |
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | HashCore | 派生クラスでオーバーライドされると、ハッシュを計算するために、オブジェクトに書き込まれたデータをハッシュ アルゴリズムにルーティングします。 (HashAlgorithm から継承されます。) |
![]() | HashFinal | 派生クラスでオーバーライドされると、暗号ストリーム オブジェクトによって最後のデータが処理された後に、ハッシュ計算を終了します。 (HashAlgorithm から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

RIPEMD
(RIPEMD-160 から転送)
出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2022/11/19 09:11 UTC 版)
一般 | |
---|---|
設計者 | Hans Dobbertin, Antoon Bosselaers, Bart Preneel |
初版発行日 | 1996 |
認証 | RIPEMD-160: CRYPTREC(運用監視) |
詳細 | |
ダイジェスト長 | 128, 160, 256, 320 bits |
RIPEMD (RACE Integrity Primitives Evaluation Message Digest) は、1996年にルーヴェン・カトリック大学COSICのHans Dobbertin、Antoon Bosselaers、Bart Preneelによって開発された暗号学的ハッシュ関数である。RIPEMDはMD4の設計原理に基づいたものであり、SHA-1と同程度のパフォーマンスを有している。
SHA-1やSHA-2がNSAによって開発されたのと対照的に、RIPEMDはオープンな学術コミュニティによって開発され、特許による制限を受けない。RIPEMD-160は、オリジナルのRIPEMDでは128ビットであるハッシュ長を160ビットにしたうえで改良を加えたものであり、RIPEMDのファミリーの中で最も広く用いられているが、SHA-1ほどは用いられていない。
160ビットだけでなく128、256、320ビットの変種もあり、それぞれRIPEMD-128、RIPEMD-256、RIPEMD-320と呼ばれている。128ビットであるRIPEMD-128は、同じく128ビットでありセキュリティ面での問題点が発見されていたオリジナルのRIPEMDを置き換えることのみを意図したものである。256および320ビットであるRIPEMD-256、RIPEMD-320はハッシュの衝突の可能性を小さくするのみであり、原像攻撃への耐性といったセキュリティレベルはRIPEMD-128やRIPEMD-160と同程度である。
2004年8月に、オリジナルのRIPEMDについてハッシュの衝突が報告された[1]。これはRIPEMD-160などには影響を及ぼさない[2]。
RIPEMD-160 のハッシュ値
RIPEMD-160によるハッシュ値は、十六進法で40桁となる。以下は、43バイトのASCII文字列を入力とした時のRIPEMD-160によるハッシュ値である。
RIPEMD-160("The quick brown fox jumps over the lazy dog") = 37f332f68db77bd9d7edd4969571ad671cf9dd3b
入力メッセージのわずかな違いも、出力されるハッシュ値には大きな違いをもたらす。d を c に変えた場合には以下のようになる。
RIPEMD-160("The quick brown fox jumps over the lazy cog") = 132072df690933835eb8b6ad0b77e7b6f14acad7
空の入力に対するハッシュ値は以下のようになる。
RIPEMD-160("") = 9c1185a5c5e9fc54612808977ee8f548b2258d31
実装ライブラリ
RIPEMDをサポートしているライブラリは以下の通り。
関連項目
脚注
- ^ Xiaoyun Wang (2004年8月17日). “Collisions for Hash Functions MD4, MD5, HAVAL-128 and RIPEMD”. 2013年12月28日閲覧。
- ^ Florian Mendel (2006年). “On the Collision Resistance of RIPEMD-160”. 2014年11月7日閲覧。
外部リンク
- RIPEMD-160: A Strengthened Version of RIPEMD (RIPEMD-160 specification and reference implementation)
- RIPEMD-160 Ecrypt page
- RIPEMD-160のページへのリンク