// Cloning message digest rather than looking it up each time
MessageDigest md = (MessageDigest) mdAlgorithm.clone();
byte[] digest = md.digest(key.getBytes("UTF-8"));
return ((digest[0] & 0xFF) << 8) + ((digest[1] & 0xFF));
} catch (UnsupportedEncodingException e) {
throw new SharderException("Error calculating hash.", e);
} catch (CloneNotSupportedException e) {
// Sun's MD5 supports cloning, so we don't expect this to happen
throw new RuntimeException(e);
}
}