-               printf("%02X ", data[i]);
-               
-               // check if a line break is needed
-               if ( breaks > 0 && !((i+1) % breaks) && (i+1 < len) ) {
-                       ++rownum;
-                       printf("\n[%02d] | ", rownum);
-               }
+       return true;
+}
+
+void hex_to_buffer(const uint8_t *buf, const uint8_t *hex_data, const size_t hex_len, const size_t hex_max_len,
+       const size_t min_str_len, const size_t spaces_between, bool uppercase) {
+
+       char *tmp = (char *)buf;
+       size_t i;
+       memset(tmp, 0x00, hex_max_len);
+
+       int maxLen = ( hex_len > hex_max_len) ? hex_max_len : hex_len;
+
+       for (i = 0; i < maxLen; ++i, tmp += 2 + spaces_between) {
+               sprintf(tmp, (uppercase) ? "%02X" : "%02x", (unsigned int) hex_data[i]);
+
+               for (int j = 0; j < spaces_between; j++)
+                       sprintf(tmp + 2 + j, " ");