Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2014-06-20 18:18:26 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-06-20 18:18:26 +0400
commit01d802976fc89b97a5a67a0dacdaf414db2651ca (patch)
tree7255693399b625ff71355501a37061c4ce503c30 /source/blender/blenlib/intern/md5.c
parentfb7c71383b8c21d7ded739b553e6c11f66f166df (diff)
BLI_md5: add a utility function to 'translate' raw 16bytes digest into a nice 32chars hexadecimal string.
That kind of stuff belongs to BLI, not specialized code like thumbs.c
Diffstat (limited to 'source/blender/blenlib/intern/md5.c')
-rw-r--r--source/blender/blenlib/intern/md5.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/md5.c b/source/blender/blenlib/intern/md5.c
index 4122f6448fd..3d1a9cdb7a4 100644
--- a/source/blender/blenlib/intern/md5.c
+++ b/source/blender/blenlib/intern/md5.c
@@ -389,3 +389,20 @@ void *md5_buffer(const char *buffer, size_t len, void *resblock)
/* Put result in desired memory area. */
return md5_read_ctx(&ctx, resblock);
}
+
+char *md5_to_hexdigest(void *resblock, char r_hex_digest[33])
+{
+ static const char hex_map[17] = "0123456789abcdef";
+ const unsigned char *p;
+ char *q;
+ short len;
+
+ for (q = r_hex_digest, p = (const unsigned char *)resblock, len = 0; len < 16; ++p, ++len) {
+ const unsigned char c = *p;
+ *q++ = hex_map[c >> 4];
+ *q++ = hex_map[c & 15];
+ }
+ *q = '\0';
+
+ return r_hex_digest;
+}