aboutsummaryrefslogtreecommitdiff
path: root/misc.cc
diff options
context:
space:
mode:
authorszszszsz <szszszsz@users.noreply.github.com>2016-09-08 16:49:52 +0200
committerGitHub <noreply@github.com>2016-09-08 16:49:52 +0200
commite164c5f3dc74fb2335b1fc573ce446cdd76a07dc (patch)
treee11e0a7458d7aae9e484722550c60292b3a6d9ba /misc.cc
parent7dbbe7fb4c50c62b0e1818c5356aafb97a00ac0f (diff)
parentbcbb54f49fad3f4bb3e8e6aca081d9d300e74d2b (diff)
downloadlibnitrokey-e164c5f3dc74fb2335b1fc573ce446cdd76a07dc.tar.gz
libnitrokey-e164c5f3dc74fb2335b1fc573ce446cdd76a07dc.tar.bz2
Merge pull request #34 from Nitrokey/issue_33
Function for getting device's serial number in hex. Fixes #33
Diffstat (limited to 'misc.cc')
-rw-r--r--misc.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/misc.cc b/misc.cc
index a31d9bc..d004d0f 100644
--- a/misc.cc
+++ b/misc.cc
@@ -6,14 +6,16 @@
namespace nitrokey {
namespace misc {
-std::string hexdump(const char *p, size_t size) {
+std::string hexdump(const char *p, size_t size, bool print_header) {
std::stringstream out;
char formatbuf[128];
const char *pstart = p;
for (const char *pend = p + size; p < pend;) {
- snprintf(formatbuf, 128, "%04lx\t", p - pstart);
- out << formatbuf;
+ if (print_header){
+ snprintf(formatbuf, 128, "%04lx\t", p - pstart);
+ out << formatbuf;
+ }
for (const char *le = p + 16; p < le && p < pend; p++) {
snprintf(formatbuf, 128, "%02x ", uint8_t(*p));