From 7b75dd9d4afd6030fe1837ea7d2d3fcd225ae785 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 20 Feb 2008 00:25:29 +0000 Subject: further cleanups cipher could work now --- buffer.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'buffer.cpp') diff --git a/buffer.cpp b/buffer.cpp index f0d7940..e8191f2 100644 --- a/buffer.cpp +++ b/buffer.cpp @@ -30,8 +30,7 @@ #include #include -#include -#include +#include #include #include #include "datatypes.h" @@ -182,18 +181,19 @@ Buffer::operator u_int8_t*() // just for write/read tun std::string Buffer::getHexDump() const { - char text[10]; - std::string ret = ""; - + std::stringstream ss; + ss << std::hex; for( u_int32_t index = 0; index < length_; index++ ) { - std::sprintf(text, "%#4x", buf_[index]); - ret += text; - ret += ""; - if( ((index+1) % 10) == 0 ) - ret += '\n'; + ss << std::setw(2) << std::setfill('0') << static_cast(buf_[index]) << " "; + if(!((index+1) % 16)) { + ss << std::endl; + continue; + } + if(!((index+1) % 8)) + ss << " "; } - return ret; + return ss.str(); } Buffer Buffer::operator^(const Buffer &xor_by) const -- cgit v1.2.3