Possible Duplicate How to reduce a bigger string in smaller string in C++? Probably by hashing?
I have tried to create my own checksum algorithm for a bmp file in java. So, for a 54 byte (432 bit) header, the resulting checksum is 378 bits long.
How can I reduce it to a smaller dataset? Any suggestions on how to implement my own hashing algorithm? (One of the conditions was to not use existing algorithms).
I have used a very simple hash function.
public static String hash_function(String bmpBytes) {
String hash = "";
int left_shift = Integer.parseInt(bmpBytes);
int right_shift = Integer.parseInt(bmpBytes);
left_shift = left_shift << 2;
right_shift = right_shift >> 2;
int xor = left_shift ^ right_shift;
hash += Integer.toString(xor);
return hash;
}
POSSIBLE ANSWER :
I found out a way to shorten my string by generating 'n' random binary bits where
n < sizeOf(hash) and then doing a hash % n-bits.
If that is a valid answer, do let me know and I shall mark the question as answered.
return ""satisfies the ones you have told: the strings is reduced to a smaller one. Should the algorithm be secure, reversible, etc.