public void testToString() { assertEquals("Hashing.sipHash24(" + K0 + ", " + K1 + ")", SIP_WITH_KEY.toString()); assertEquals("Hashing.sipHash24(" + K0 + ", " + K1 + ")", SIP_WITHOUT_KEY.toString()); assertEquals("Hashing.sipHash24(20, 13)", Hashing.sipHash24(20, 13).toString()); }
public void testCollisionsDueToIncorrectSignExtension() { byte[] col1 = new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, (byte) 0x80}; byte[] col2 = new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, (byte) 0x81}; byte[] col3 = new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, (byte) 0xff}; ImmutableSet<HashCode> hashCodes = ImmutableSet.of( SIP_WITH_KEY.hashBytes(col1), SIP_WITH_KEY.hashBytes(col2), SIP_WITH_KEY.hashBytes(col3)); assertEquals(3, hashCodes.size()); }
private static void assertSip(byte[] input, long expected) { assertEquals(expected, SIP_WITH_KEY.hashBytes(input).asLong()); assertEquals(expected, SIP_WITH_KEY.newHasher().putBytes(input).hash().asLong()); assertEquals(expected, SIP_WITHOUT_KEY.hashBytes(input).asLong()); assertEquals(expected, SIP_WITHOUT_KEY.newHasher().putBytes(input).hash().asLong()); } }
private static void assertSip(String input, long expected) { assertEquals(expected, SIP_WITH_KEY.hashString(input, UTF_8).asLong()); assertEquals(expected, SIP_WITH_KEY.newHasher().putString(input, UTF_8).hash().asLong()); assertEquals(expected, SIP_WITHOUT_KEY.hashString(input, UTF_8).asLong()); assertEquals(expected, SIP_WITHOUT_KEY.newHasher().putString(input, UTF_8).hash().asLong()); }
public void test15ByteStringFromSipHashPaper() { byte[] message = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e }; long k0 = 0x0706050403020100L; long k1 = 0x0f0e0d0c0b0a0908L; assertEquals(0xa129ca6149be45e5L, Hashing.sipHash24(k0, k1).hashBytes(message).asLong()); }
public void testToString() { assertEquals("Hashing.sipHash24(" + K0 + ", " + K1 + ")", SIP_WITH_KEY.toString()); assertEquals("Hashing.sipHash24(" + K0 + ", " + K1 + ")", SIP_WITHOUT_KEY.toString()); assertEquals("Hashing.sipHash24(20, 13)", Hashing.sipHash24(20, 13).toString()); }
public void testCollisionsDueToIncorrectSignExtension() { byte[] col1 = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, (byte) 0x80 }; byte[] col2 = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, (byte) 0x81 }; byte[] col3 = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, (byte) 0xff }; ImmutableSet<HashCode> hashCodes = ImmutableSet.of( SIP_WITH_KEY.hashBytes(col1), SIP_WITH_KEY.hashBytes(col2), SIP_WITH_KEY.hashBytes(col3)); assertEquals(3, hashCodes.size()); }
private static void assertSip(String input, long expected) { assertEquals(expected, SIP_WITH_KEY.hashString(input, UTF_8).asLong()); assertEquals(expected, SIP_WITH_KEY.newHasher().putString(input, UTF_8).hash().asLong()); assertEquals(expected, SIP_WITHOUT_KEY.hashString(input, UTF_8).asLong()); assertEquals(expected, SIP_WITHOUT_KEY.newHasher().putString(input, UTF_8).hash().asLong()); }
private static void assertSip(byte[] input, long expected) { assertEquals(expected, SIP_WITH_KEY.hashBytes(input).asLong()); assertEquals(expected, SIP_WITH_KEY.newHasher().putBytes(input).hash().asLong()); assertEquals(expected, SIP_WITHOUT_KEY.hashBytes(input).asLong()); assertEquals(expected, SIP_WITHOUT_KEY.newHasher().putBytes(input).hash().asLong()); } }
public void test15ByteStringFromSipHashPaper() { byte[] message = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e }; long k0 = 0x0706050403020100L; long k1 = 0x0f0e0d0c0b0a0908L; assertEquals(0xa129ca6149be45e5L, Hashing.sipHash24(k0, k1).hashBytes(message).asLong()); }