Moderators: phlip, Prelates, Moderators General
Rysto wrote:What's your hash function?
joeframbach wrote:md5 you say?
well I guess there's only one way to find out. There's a finite number of possible strings. Get crackin.
#include <vector>
#include <assert.h>
static bool progress_report = true;
static unsigned int progress_freq = 100000;
typedef unsigned int (*hash_function)( unsigned char* data, size_t length );
bool find_to_itself( hash_function hash, unsigned int* result, size_t min_length_ = 0 ) {
unsigned int min_length = (min_length_<sizeof(unsigned int))?sizeof(unsigned int):min_length);
std::vector<unsigned char> buff(min_length);
unsigned char* buff_ptr = &buff.front();
unsigned int* data_ptr = reinterpret_cast<unsigned int*>(buff_ptr);
if (!data_ptr) {
assert(false);
return false;
}
unsigned int& data = *data_ptr;
data = 0;
unsigned int hash_result = hash_function( &buff.front(), min_length );
if (hash_result == data) {
if (result) *result = data;
return true;
}
while( (++data) != 0 ) {
hash_result = hash_function( &buff.front(), min_length );
if (hash_result == data) {
if (result) *result = data;
return true;
}
if (progress_report) {
if ((progress_freq % data) == 0) {
printf("Progress: up to %d checked\n", data);
}
}
}
return false;
}
void main() {
unsigned int result = 0;
bool found = find_to_itself( md5hash, &result );
if (found) {
printf("Found: %d hashes to itself\n", result);
} else {
printf("No self-hash found\n");
}
}
xyzzy wrote:Simple.First, generate all possible MD5 hashes
Second, hash them all.
Third, compare the two for any items that match themselves
Done.
You'll be wanting a supercomputer to do this quickly though.
Rysto wrote:SHA-5 gives a 128-bit hash.
Users browsing this forum: No registered users and 2 guests