Changeset 2466

Show
Ignore:
Timestamp:
08/18/07 04:31:22 (1 year ago)
Author:
paule
Message:

Make hash_str() return a printable string of the md5 hash instead of the raw hash itself

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/opie-sync/src/opie_xml.c

    r2461 r2466  
    218218 
    219219char *hash_str(const char *str) { 
    220         unsigned char* t_hash; 
    221          
    222         t_hash = g_malloc0(MD5_DIGEST_LENGTH + 1); 
    223          
    224         md5(str, strlen(str), t_hash); 
    225         return t_hash; 
     220        unsigned char* hash; 
     221        GString *hash_printable; 
     222        int i; 
     223         
     224        hash = g_malloc0(MD5_DIGEST_LENGTH + 1); 
     225         
     226        md5(str, strlen(str), hash); 
     227         
     228        hash_printable = g_string_sized_new((MD5_DIGEST_LENGTH * 2) + 1); 
     229        for(i=0; i<MD5_DIGEST_LENGTH; i++) 
     230                g_string_append_printf(hash_printable, "%02x", hash[i]); 
     231                 
     232        char *hash_str = hash_printable->str; 
     233        g_string_free(hash_printable, FALSE); 
     234        g_free(hash); 
     235        return hash_str; 
    226236} 
    227237