static byte[] stringDigest(String s) throws NumberFormatException {
  byte[] result=new byte[(s.length() + 1) / 2];
  int rpos=result.length;
  int last=-1;
  for (int spos=s.length(); --spos >= 0; ) {
    int digit=Character.digit(s.charAt(spos),16);
    if (digit < 0) {
      throw new NumberFormatException("Illegal hex digit: '" + s.charAt(spos) + "'");
    }
    if (last < 0) {
      last=digit;
    }
 else {
      result[--rpos]=(byte)(last + (digit << 4));
      last=-1;
    }
  }
  if (last >= 0) {
    result[--rpos]=(byte)last;
  }
  return result;
}

static byte [ ] stringDigest ( String s ) throws NumberFormatException { byte [ ] result = new byte [ ( s . length ( ) + 1 ) / 2 ] ; int rpos = result . length ; int last = - 1 ; for ( int spos = s . length ( ) ; -- spos >= 0 ; ) { int digit = Character . digit ( s . charAt ( spos ) , 16 ) ; if ( digit < 0 ) { throw new NumberFormatException ( "Illegal hex digit: '" + s . charAt ( spos ) + "'" ) ; } if ( last < 0 ) { last = digit ; } else { result [ -- rpos ] = ( byte ) ( last + ( digit << 4 ) ) ; last = - 1 ; } } if ( last >= 0 ) { result [ -- rpos ] = ( byte ) last ; } return result ; }
converts a string in hexadecimal format to a message digest .
