public static int intHash(String ipString){
  int val=0;
  String[] strs=ipString.split("[^\\p{XDigit}]");
  int len=strs.length;
  if (len >= 4) {
    val=intVal(strs[0]);
    val<<=8;
    val|=intVal(strs[1]);
    val<<=8;
    val|=intVal(strs[2]);
    val<<=8;
    val|=intVal(strs[3]);
  }
  return val;
}

public static int intHash ( String ipString ) { int val = 0 ; String [ ] strs = ipString . split ( "[^\\p{XDigit}]" ) ; int len = strs . length ; if ( len >= 4 ) { val = intVal ( strs [ 0 ] ) ; val <<= 8 ; val |= intVal ( strs [ 1 ] ) ; val <<= 8 ; val |= intVal ( strs [ 2 ] ) ; val <<= 8 ; val |= intVal ( strs [ 3 ] ) ; } return val ; }
this should be suitable for ipv6 as well but we will have to accommodate for the extra bytes later . expects four integers 0 - 255 separated by some non - numeric character .
