summaryrefslogtreecommitdiff
path: root/source3/lib/data_blob.c
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-04-25 20:06:19 +0200
committerGünther Deschner <gd@samba.org>2008-04-29 20:22:01 +0200
commitad73cb11a2a650ece09e3989f5b019234d9517ff (patch)
tree55df80d07941cafe901cc7e528dae6472843dd69 /source3/lib/data_blob.c
parent0173eeb3b5c0e67a58c43089d5b152bfd307de80 (diff)
downloadsamba-ad73cb11a2a650ece09e3989f5b019234d9517ff.tar.gz
samba-ad73cb11a2a650ece09e3989f5b019234d9517ff.tar.bz2
samba-ad73cb11a2a650ece09e3989f5b019234d9517ff.zip
Merge data_blob_hex_string from Samba4.
Guenther (This used to be commit 686d8939d90eab958d3a352fe53917ba7a17f39a)
Diffstat (limited to 'source3/lib/data_blob.c')
-rw-r--r--source3/lib/data_blob.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c
index daba17df14..66c5daf363 100644
--- a/source3/lib/data_blob.c
+++ b/source3/lib/data_blob.c
@@ -156,3 +156,25 @@ DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length)
data_blob_clear(&blob);
return blob;
}
+
+/**
+print the data_blob as hex string
+**/
+_PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob)
+{
+ int i;
+ char *hex_string;
+
+ hex_string = talloc_array(mem_ctx, char, (blob->length*2)+1);
+ if (!hex_string) {
+ return NULL;
+ }
+
+ for (i = 0; i < blob->length; i++)
+ slprintf(&hex_string[i*2], 3, "%02X", blob->data[i]);
+
+ hex_string[(blob->length*2)] = '\0';
+ return hex_string;
+}
+
+