summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-11-05 14:44:20 -0500
committerDan Williams <dcbw@redhat.com>2010-11-05 14:44:20 -0500
commit2a98b2ae2d2541e78fad4d931a84094f3b00773a (patch)
tree5a4e2ebd7d9117e08654367464b672e6eec09fc5
parent6921a9f71d7d6b4cc60f7fa776d62ef8f814ec76 (diff)
core: add bin -> hex string converter
-rw-r--r--src/mm-utils.c14
-rw-r--r--src/mm-utils.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/src/mm-utils.c b/src/mm-utils.c
index 56182c0c..c435d1d6 100644
--- a/src/mm-utils.c
+++ b/src/mm-utils.c
@@ -76,3 +76,17 @@ utils_hexstr2bin (const char *hex, gsize *out_len)
/* End from hostap */
+char *
+utils_bin2hexstr (const guint8 *bin, gsize len)
+{
+ GString *ret;
+ gsize i;
+
+ g_return_val_if_fail (bin != NULL, NULL);
+
+ ret = g_string_sized_new (len * 2 + 1);
+ for (i = 0; i < len; i++)
+ g_string_append_printf (ret, "%.2X", bin[i]);
+ return g_string_free (ret, FALSE);
+}
+
diff --git a/src/mm-utils.h b/src/mm-utils.h
index 79e7827b..1b9b328f 100644
--- a/src/mm-utils.h
+++ b/src/mm-utils.h
@@ -20,5 +20,7 @@ int utils_hex2byte (const char *hex);
char *utils_hexstr2bin (const char *hex, gsize *out_len);
+char *utils_bin2hexstr (const guint8 *bin, gsize len);
+
#endif /* MM_UTILS_H */