equal
deleted
inserted
replaced
199 p += snprintf(p, last + 1 - p, "%02X", md5sum[i]); |
199 p += snprintf(p, last + 1 - p, "%02X", md5sum[i]); |
200 if (p >= last) break; |
200 if (p >= last) break; |
201 } |
201 } |
202 |
202 |
203 return p; |
203 return p; |
|
204 } |
|
205 |
|
206 /** Convert the hexadecimal string representation to a binary md5sum |
|
207 * @param md5sum where to put the md5sum into |
|
208 * @param buf buffer containing a string of 32 hex chars |
|
209 * @return 0 on success, -1 on failure */ |
|
210 int StringToMd5sum(uint8 md5sum[16], const char *buf) |
|
211 { |
|
212 char hex[3] = { 0, 0, 0}; |
|
213 char *invalid; |
|
214 |
|
215 for (uint i = 0; i < 16; i++) { |
|
216 hex[0] = buf[i * 2 + 0]; |
|
217 hex[1] = buf[i * 2 + 1]; |
|
218 |
|
219 md5sum[i] = strtol(hex, &invalid, 16); |
|
220 |
|
221 if (*invalid) |
|
222 return -1; |
|
223 } |
|
224 |
|
225 return 0; |
204 } |
226 } |
205 |
227 |
206 |
228 |
207 /* UTF-8 handling routines */ |
229 /* UTF-8 handling routines */ |
208 |
230 |