RIPEMD and GOST Hashing ExampleRIPEMD is a 128-bit, 160-bit, 256-bit or 320-bit cryptographic hash function, and was created by Hans Dobbertin, Antoon Bosselaers and Bart Preneel. It is used on TrueCrypt, and is open source. The 160-bit version is seen as an alternative to SHA-1, and is part of ISO/IEC 10118 [Theory]. Also included on this page is GOST, in which GOST R 34.11-94 and GOST 34.311-95 are 256-bit hash functions. It has been standardized with the Russian national standard of 34.11-94 Information Technology - Cryptographic Information Security - Hash Function. The results are then:
|
Examples
- Try "The quick brown fox jumps over the lazy dog". Try!, which should give a RIPEMD128 hash of: 3fa9b57f053c053fbe2735b2380db596 Check
- Try "Test vector from febooti.com". Try!, which should give a RIPEMD128 hash of: ab076efaab01d30d16bb57f88d63c073Check
- Try "". Try!, which should give a RIPEMD128 hash of: cdf26213a150dc3ecb610f18f6b38b46 Check
- Try "a". Try!, which should give a RIPEMD128 hash of: 86be7afa339d0fc7cfc785e72f578d33 Check
- Try "abc". Try!, which should give a RIPEMD128 hash of: c14a12199c66e4ba84636b0f69144c77 Check
- Try "message digest". Try!, which should give a RIPEMD128 hash of: 9e327b3d6e523062afc1132d7df9d1b8 Check
- Try "". Try!, which should give a GOST hash of: 981e5f3ca30c841487830f84fb433e13ac1101569b9c13584ac483234cd656c0 Check
- Try "The quick brown fox jumps over the lazy dog". Try!, which should give a GOST hash of: 9004294a361a508c586fe53d1f1b02746765e71b765472786e4770d565830a76 Check
Sample code
using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto.Modes; using Org.BouncyCastle.Crypto.Engines; using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Math; using Org.BouncyCastle.Crypto.Paddings; public void checkRip(string message) { byte[] data = null; byte[] o = null; if (message == null) return; System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); Org.BouncyCastle.Crypto.Digests.RipeMD128Digest w = new Org.BouncyCastle.Crypto.Digests.RipeMD128Digest(); data = encoding.GetBytes(message); w.Reset();w.BlockUpdate(data, 0, data.Length); o = new byte[w.GetDigestSize()]; w.DoFinal(o, 0); RipeMD128 = ByteToString(o); Org.BouncyCastle.Crypto.Digests.RipeMD160Digest w1 = new Org.BouncyCastle.Crypto.Digests.RipeMD160Digest(); data = encoding.GetBytes(message); w1.Reset(); w1.BlockUpdate(data, 0, data.Length); o = new byte[w1.GetDigestSize()]; w1.DoFinal(o, 0); RipeMD160 = ByteToString(o); Org.BouncyCastle.Crypto.Digests.RipeMD256Digest w2 = new Org.BouncyCastle.Crypto.Digests.RipeMD256Digest(); data = encoding.GetBytes(message); w2.Reset(); w2.BlockUpdate(data, 0, data.Length); o = new byte[w2.GetDigestSize()]; w2.DoFinal(o, 0); RipeMD256 = ByteToString(o); } public static string ByteToString(CryptoStream buff) { string sbinary = ""; int b = 0; do { b = buff.ReadByte(); if (b != -1) sbinary += ((char)b); } while (b != -1); return (sbinary); }