CollisionDJBX33X implements CollisionInterface { @Override public int getHash( String s ) { byte[] byteArray = s.getBytes(); int n = byteArray.length; int hash = 5381; for ( int i = 0; i < n; i++ ) { hash = ( ( hash << 5 ) + hash ) ^ byteArray[i]; } return hash; }  @Override int getHash( String s ); int hashBack( String s, int target ); int hashForth( String s ); @Override void genNCollisions( int n, StringBuilder sb, boolean useNamespace ); @Override String getCollisionString( int i, int n ); String getRandomString( int length ); String getIthNCharString( int i, int n ); int generateCollionsMeetInTheMiddle( long numberCollisions );  }
@Test public void testGetHash() { String s = "QCMWaIOvpl"; CollisionDJBX33X instance = new CollisionDJBX33X(); int expResult = 0; int result = instance.getHash( s ); assertEquals( expResult, result ); }
@Test public void testCollisionsFail() { CollisionDJBX33X instance = new CollisionDJBX33X(); int t1 = instance.getHash( "QCMWaIOvpl" ); int t2 = instance.getHash( "QCMWalOwQl" ); if ( t1 != t2 ) { assertTrue( true ); } else { assertTrue( false ); } }
@Test public void testCollisionsOk() { CollisionDJBX33X instance = new CollisionDJBX33X(); int t1 = instance.getHash( "QCMWaIOvpl" ); int t2 = instance.getHash( "QCMWaIOwQl" ); if ( t1 == t2 ) { assertTrue( true ); } else { assertTrue( false ); } }