From 7f7959778cc67a1cb48e329cd70eb003c6d0b234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Fri, 12 Apr 2024 03:21:41 +0200 Subject: [PATCH] Extract hexDump function --- src/util.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/util.h b/src/util.h index a563f9c..c7bd54e 100644 --- a/src/util.h +++ b/src/util.h @@ -246,6 +246,19 @@ enum class ExtendedChar { GreekSmallLetterPhi = 0xed, }; +String hexDump(String in) { + String out; + for (size_t i = 0; i < in.length(); ++i) { + auto hexChar = String(in[i], HEX); + if (hexChar.length() == 1) { + out.concat('0'); + } + out.concat(hexChar); + out.concat(' '); + } + return out; +} + /* * Message syntax: * separator: ~