src/string.cpp
changeset 5885 262234e81333
parent 5882 5ba219322829
child 6298 c30fe89622df
child 6541 ff575414f0d2
--- a/src/string.cpp	Sat Jan 13 13:33:36 2007 +0000
+++ b/src/string.cpp	Sat Jan 13 13:47:57 2007 +0000
@@ -177,6 +177,24 @@
 #endif /* WIN32 */
 
 
+/** Convert the md5sum to a hexadecimal string representation
+ * @param buf buffer to put the md5sum into
+ * @param last last character of buffer (usually lastof(buf))
+ * @param md5sum the md5sum itself
+ * @return a pointer to the next character after the md5sum */
+char *md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
+{
+	char *p = buf;
+
+	for (uint i = 0; i < 16; i++) {
+		p += snprintf(p, last + 1 - p, "%02X", md5sum[i]);
+		if (p >= last) break;
+	}
+
+	return p;
+}
+
+
 /* UTF-8 handling routines */