Though I am a glib fan, I really cannot use the g_checksum_* functions to obtain an MD5 string that is compatible with the md5sum command.
Any idea on what is wrong with this code?Code:gchar *get_hash(const gchar *filepath) { FILE *fp; if (NULL != (fp = fopen(filepath, "r+b"))) { guchar buffer[65536]; gint read_bytes; gchar *result; GChecksum *checksum = g_checksum_new(hash_type); while ((read_bytes = fread(buffer, sizeof(buffer), 1, fp)) > 0) g_checksum_update(checksum, buffer, read_bytes); fclose(fp); result = (gchar *) g_checksum_get_string(checksum); g_checksum_free(checksum); return result; } return ""; }
Thanks in advance for any help and or suggestion



LinkBack URL
About LinkBacks


