public static void TestOneMillionBytes() { var message = Enumerable.Repeat((byte)0, 1000000).ToArray(); using (var hash = new SipHash(SpecificationKey)) AssertEqual(hash.ComputeHash(message), 0x28205108397aa742UL); }
public static void TestSevenBytes() { var message = Encoding.UTF8.GetBytes("SipHash"); using (var hash = new SipHash(SpecificationKey)) AssertEqual(hash.ComputeHash(message), 0x8325093242a96f60UL); }
public static void TestEightBytes() { var message = Encoding.UTF8.GetBytes("12345678"); using (var hash = new SipHash(SpecificationKey)) AssertEqual(hash.ComputeHash(message), 0x2130609caea37ebUL); }
public static void TestSixBytes() { var message = Encoding.UTF8.GetBytes("abcdef"); using (var hash = new SipHash(SpecificationKey)) AssertEqual(hash.ComputeHash(message), 0x2a6e77e733c7c05dUL); }
public static void TestSingleByte() { var message = new byte[] { 0x61 }; using (var hash = new SipHash(SpecificationKey)) AssertEqual(hash.ComputeHash(message), 0x2ba3e8e9a71148caUL); }
public static void TestEmptyMessage() { var message = new byte[0]; using (var hash = new SipHash(SpecificationKey)) AssertEqual(hash.ComputeHash(message), 0x726fdb47dd0e0e31UL); }
public string CalculateHash(string message, string littleEndianKey) { var messageBytes = Encoding.ASCII.GetBytes(message); var byteKey = BigInteger.Parse(littleEndianKey, NumberStyles.HexNumber).ToByteArray(); var hasher = new SipHash(byteKey); var hash = hasher.ComputeHash(messageBytes); var stringHash = BitConverter.ToUInt64(hash, 0).ToString("X"); return PadHash(stringHash); }
internal SipState(byte[] key, int compressionRounds, int finalizationRounds) { SipHash.ValidateArguments(key, compressionRounds, finalizationRounds); var k0 = BitConverter.ToUInt64(key, 0); var k1 = BitConverter.ToUInt64(key, 8); // "somepseudorandomlychosenbytes". See §4 _v[0] = 0x736f6d6570736575UL ^ k0; _v[1] = 0x646f72616e646f6dUL ^ k1; _v[2] = 0x6c7967656e657261UL ^ k0; _v[3] = 0x7465646279746573UL ^ k1; CompressionRounds = compressionRounds; FinalizationRounds = finalizationRounds; }
public static void TestBlockHash(int blockSize) { using (var hash = new SipHash(SpecificationKey)) AssertEqual(BlockHash(hash, SpecificationMessage, 0, blockSize), 0xa129ca6149be45e5UL); }
/*** * Tests adapted from https://github.com/emboss/siphash-java/blob/master/test/com/github/emboss/siphash/SipHashTest.java * Thanks to Martin Boßlet for these, which allowed me to quickly verify (presumable) correct functionality. ***/ public static void TestSpecification() { using (var hash = new SipHash(SpecificationKey)) AssertEqual(hash.ComputeHash(SpecificationMessage), 0xa129ca6149be45e5UL); }