now secure channel enabled

This commit is contained in:
Marc Wäckerlin
2009-10-14 13:31:27 +00:00
parent 9a3ea17b11
commit 7840897598
5 changed files with 269 additions and 3 deletions

View File

@@ -30,8 +30,16 @@ namespace crypto {
static const std::string VALID_CHARS
(LETTER_CHARS+NUMBER_CHARS+GRAFIC_CHARS+BLANK_CHARS);
inline std::string hex(const std::string& data,
std::string::size_type len=20) {
inline std::string hex(const std::string& data) {
std::stringstream res;
for (std::string::const_iterator it(data.begin()); it!=data.end(); ++it)
res<<std::hex<<std::setfill('0')<<std::setw(2)
<<(unsigned int)(unsigned char)*it;
return res.str();
}
inline std::string hexTxt(const std::string& data,
std::string::size_type len=20) {
std::stringstream res;
std::string::size_type pos(0);
for (std::string::const_iterator it(data.begin()); it!=data.end(); ++it) {
@@ -53,7 +61,7 @@ namespace crypto {
if (!data.size())
return "<empty>";
else if (data.find_first_not_of(VALID_CHARS)<data.size())
return hex(data);
return hexTxt(data);
else
return "\""+data+"\"";
}