| 57 | #include "./md5.h" |
| 58 | |
| 59 | static char *MD5End(MD5_CTX *ctx, char *buf) |
| 60 | { |
| 61 | int i; |
| 62 | unsigned char digest[LENGTH]; |
| 63 | static const char hex[] = "0123456789abcdef"; |
| 64 | |
| 65 | if (!buf) |
| 66 | buf = malloc(2 * LENGTH + 1); |
| 67 | if (!buf) |
| 68 | return 0; |
| 69 | MD5Final(digest, ctx); |
| 70 | for (i = 0; i < LENGTH; i++) { |
| 71 | buf[i + i] = hex[digest[i] >> 4]; |
| 72 | buf[i + i + 1] = hex[digest[i] & 0x0f]; |
| 73 | } |
| 74 | buf[i + i] = '\0'; |
| 75 | return buf; |
| 76 | } |
| 77 | |
| 78 | char *MD5File(const char *filename, char *buf) |
| 79 | { |
no test coverage detected