I need to create a checksum consisting in several objects of basic types. I read the "Writing a correct hashCode method" section in THIS page. I need something similar working (and returning the same values for the same inputs) in java, php and objectivec.
How can I do it? is there some library I can use?
Edit (my current code):
public class CheckSumGenerator {
private final static String SEPARATOR = "|";
private final static String DOUBLE_FORMAT = "%.30f";
private final static DecimalFormat FORMAT_DOUBLE=new DecimalFormat("#.#################################");
StringBuilder tempChain = new StringBuilder();
public void putInt(int value) {
tempChain.append(SEPARATOR).append(value);
}
public void putLong(long value) {
tempChain.append(SEPARATOR).append(value);
}
public void putString(String value) {
tempChain.append(SEPARATOR).append(value);
}
public void putBoolean(boolean value) {
tempChain.append(SEPARATOR).append(value ? 1 : 0);
}
public void putDouble(double value) {
tempChain.append(SEPARATOR).append(FORMAT_DOUBLE.format(value));
}
public String getChecksum() {
return HashUtils.MD5(tempChain.toString());
}
}