From a0e44c30e21013f0136ddefc1bbbdc020413e749 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 3 Feb 2012 03:27:19 +0100 Subject: lib/util: Add hex_encode_buf Autobuild-User: Volker Lendecke Autobuild-Date: Mon Feb 6 09:15:33 CET 2012 on sn-devel-104 --- lib/util/samba_util.h | 5 +++++ lib/util/util.c | 25 ++++++++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'lib/util') diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index 9df3ddfcd0..5ce2e5e535 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -261,6 +261,11 @@ _PUBLIC_ size_t strhex_to_str(char *p, size_t p_len, const char *strhex, size_t */ _PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *strhex) ; +/** + * Print a buf in hex. Assumes dst is at least (srclen*2)+1 large. + */ +_PUBLIC_ void hex_encode_buf(char *dst, const uint8_t *src, size_t srclen); + /** * Routine to print a buffer as HEX digits, into an allocated string. */ diff --git a/lib/util/util.c b/lib/util/util.c index c4fbd0b39f..867da0a340 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -758,20 +758,31 @@ _PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *s return ret_blob; } +/** + * Print a buf in hex. Assumes dst is at least (srclen*2)+1 large. + */ +_PUBLIC_ void hex_encode_buf(char *dst, const uint8_t *src, size_t srclen) +{ + size_t i; + for (i=0; i