Changeset 1174899


Ignore:
Timestamp:
2011-07-31T14:40:41Z (8 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
aa9f1ac
Parents:
4a5d885
Message:

Having written the same stupid code (ASCII MD5 hashes) 205762 times, time to
have a function for it..

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/md5.c

    r4a5d885 r1174899  
    160160        memcpy(digest, ctx->buf, 16);
    161161        memset(ctx, 0, sizeof(ctx));    /* In case it's sensitive */
     162}
     163
     164void md5_finish_ascii(struct MD5Context *context, char *ascii)
     165{
     166        md5_byte_t bin[16];
     167        int i;
     168       
     169        md5_finish(context, bin);
     170        for (i = 0; i < 16; i ++)
     171                sprintf(ascii + i * 2, "%02x", bin[i]);
    162172}
    163173
  • lib/md5.h

    r4a5d885 r1174899  
    4343G_MODULE_EXPORT void md5_append(struct MD5Context *context, const md5_byte_t *buf, unsigned int len);
    4444G_MODULE_EXPORT void md5_finish(struct MD5Context *context, md5_byte_t digest[16]);
     45G_MODULE_EXPORT void md5_finish_ascii(struct MD5Context *context, char *ascii);
    4546
    4647#endif
Note: See TracChangeset for help on using the changeset viewer.