From ad73cb11a2a650ece09e3989f5b019234d9517ff Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 25 Apr 2008 20:06:19 +0200 Subject: Merge data_blob_hex_string from Samba4. Guenther (This used to be commit 686d8939d90eab958d3a352fe53917ba7a17f39a) --- source3/lib/data_blob.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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; +} + + -- cgit