CollisionDJBX implements CollisionInterface { @Override public int getHash( String s ) { byte[] byteArray = s.getBytes( Charset.defaultCharset() ); int n = byteArray.length; int key = 0; for ( int i = 0; i < n; i++ ) { int h = key; key = key << 10; for ( int ab = 0; ab < 6; ab++ ) { key = ( key << 1 ) + h; } key = key + byteArray[i]; } key = key + ( key >> 5 ); return key; }  int getLengthString(); void setLengthString( int lengthString ); int getLengthSuffix(); void setLengthSuffix( int lengthSuffix ); @Override int getHash( String s ); int hashForth( String s ); int hashBack( String s, int target ); @Override void genNCollisions( int numberAttributes, StringBuilder sb, boolean useNamespace ); @Override String getCollisionString( int i, int n ); Set<String> generateCollionsMeetInTheMiddle( long numberCollisions ); String getIthNCharString( int i, int n );  }
@Test public void test() { assertThat( collisionDJBX.getHash( "0" ), is( 49 ) ); assertThat( collisionDJBX.getHash( "9" ), is( 58 ) ); assertThat( collisionDJBX.getHash( "A" ), is( 67 ) ); assertThat( collisionDJBX.getHash( "Z" ), is( 92 ) ); assertThat( collisionDJBX.getHash( "a" ), is( 100 ) ); assertThat( collisionDJBX.getHash( "z" ), is( 125 ) ); assertThat( collisionDJBX.getHash( "aa" ), is( 6562050 ) ); assertThat( collisionDJBX.getHash( "bb" ), is( 6629700 ) ); assertThat( collisionDJBX.getHash( "AA" ), is( 4397250 ) ); assertThat( collisionDJBX.getHash( "000" ), is( 412191697 ) ); assertThat( collisionDJBX.getHash( "009" ), is( 412191706 ) ); assertThat( collisionDJBX.getHash( "00A" ), is( 412191715 ) ); assertThat( collisionDJBX.getHash( "00Z" ), is( 412191740 ) ); assertThat( collisionDJBX.getHash( "00a" ), is( 412191748 ) ); assertThat( collisionDJBX.getHash( "900" ), is( 488868790 ) ); assertThat( collisionDJBX.getHash( "Z00" ), is( 770018132 ) ); assertThat( collisionDJBX.getHash( "zzz" ), is( 1047653897 ) ); assertThat( collisionDJBX.getHash( "0000" ), is( -811407168 ) ); assertThat( collisionDJBX.getHash( "0zzz" ), is( -175944968 ) ); assertThat( collisionDJBX.getHash( "2PUz" ), is( 1073686683 ) ); }
@Test public void complexTest() { assertThat( collisionDJBX.getHash( "2PV0" ), is( 1073754255 ) ); assertThat( collisionDJBX.getHash( "test" ), is( 1233125307 ) ); assertThat( collisionDJBX.getHash( "waddehaddedudeda" ), is( -671098362 ) ); }