/*************************************************************************** * * hash_from_ascii * * Converts a hash string into a binary hash and puts the result into * destbuf. destbuf must be large enough to take hash. * * No input checking is performed. * * returns destbuf * ***************************************************************************/ guint8 * hash_from_ascii (const gchar *hash_str, guint8 *destbuf) { gchar hexnum[3] = { 0x00, 0x00, 0x00 }; gint i; g_return_val_if_fail (destbuf != NULL, NULL); g_return_val_if_fail (hash_str != NULL, NULL); for (i = 0; i < 16; ++i) { strncpy (hexnum, hash_str+(i*2), 2); destbuf[i] = (guint8) strtol (hexnum, NULL, 16); } return destbuf; }