Tiger Example
[Hashing Home][Home]
Tiger is a 192-bit hash function, and was designed by Ross Anderson and Eli Biham in 1995. It is often used by clients within Gnutella file sharing networks, and does not suffer from known attacks on MD5 and SHA-0/SHA-1. Tiger2 is an addition, in which the message is padded with a byte of 0x80 (in a similar way to MD4, MD5 and SHA), whereas in Tiger it is 0x01. Otherwise the two methods are the same in their operation. [Theory]
The results are then:
|
Examples
- Try "The quick brown fox jumps over the lazy dog". Try!, which should give a Tiger hash of: 6d12a41e72e644f017b6f0e2f7b44c6285f06dd5d2c5b075 Check and Check
- Try "The quick brown fox jumps over the lazy cog". Try!, which should give a Tiger hash of: a8f04b0f7201a0d728101c9d26525b31764a3493fcd8458f Check
- Try "Test vector from febooti.com". Try!, which should give a Tiger hash of: 382599758b759db703d4940c08c3393182adad7e9a7e590f Check and
- Try "". Try!, which should give a Tiger hash of: 3293ac630c13f0245f92bbb1766e16167a4e58492dde73f3 Check and 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 checkTiger(string message) { if (message == null) return; System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); Org.BouncyCastle.Crypto.Digests.TigerDigest w = new Org.BouncyCastle.Crypto.Digests.TigerDigest(); byte[] data = encoding.GetBytes(message); w.Reset(); w.BlockUpdate(data, 0, data.Length); byte[] o = new byte[w.GetDigestSize()]; w.DoFinal(o, 0); hash = ByteToString(o); } public static string ByteToString(byte[] buff) { string sbinary = ""; for (int i = 0; i < buff.Length; i++) { sbinary += buff[i].ToString("X2"); // hex format } return (sbinary); }
Tiger 2
For the Tiger 2 algorithm, we have used Hashlib. The code is then:
using HashLib; public void checkTiger2(string message) { if (message == null) return; IHash hash = HashFactory.Crypto.CreateTiger2(); HashResult r = hash.ComputeString(message, System.Text.Encoding.ASCII); byte[] o = r.GetBytes(); tiger2= ByteToString(o); }