Changeset 5112


Ignore:
Timestamp:
Feb 25, 2008, 8:21:22 PM (14 years ago)
Author:
charles
Message:

added tr_sha1_to_hex()

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/metainfo.c

    r5065 r5112  
    193193    }
    194194
    195     for( i = 0; i < SHA_DIGEST_LENGTH; i++ )
    196     {
    197         snprintf( inf->hashString + i * 2, sizeof( inf->hashString ) - i * 2,
    198                   "%02x", inf->hash[i] );
    199     }
     195    tr_sha1_to_hex( inf->hashString, inf->hash );
    200196    savedname( inf->torrent, sizeof( inf->torrent ), inf->hashString, tag );
    201197
  • trunk/libtransmission/utils.c

    r5065 r5112  
    884884    return ratio;
    885885}
     886
     887void
     888tr_sha1_to_hex( char * out, const uint8_t * sha1 )
     889{
     890    static const char hex[] = "0123456789abcdef";
     891    int i;
     892    for (i = 0; i < 20; i++) {
     893        unsigned int val = *sha1++;
     894        *out++ = hex[val >> 4];
     895        *out++ = hex[val & 0xf];
     896    }
     897    *out = '\0';
     898}
  • trunk/libtransmission/utils.h

    r5065 r5112  
    139139int tr_compareUint32( uint32_t a, uint32_t b );
    140140
     141void tr_sha1_to_hex( char * out, const uint8_t * sha1 );
     142
    141143/***
    142144****
Note: See TracChangeset for help on using the changeset viewer.