X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspstring.cpp;h=ff9c1875f2e6809080a8bf9f68c396c203b825ed;hb=a8878569083bfa4753e9e118adee0ed1da6a0325;hp=f11ea1248b218fe3a4157957878bbad12fcf2496;hpb=b6dbd6caab62bc2c0d11ce5a45d511611eb9c2ef;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspstring.cpp b/src/inspstring.cpp index f11ea1248..ff9c1875f 100644 --- a/src/inspstring.cpp +++ b/src/inspstring.cpp @@ -136,3 +136,19 @@ CoreExport bool charremove(char* mp, char remove) return shift_down; } + +static const char hextable[] = "0123456789abcdef"; + +std::string BinToHex(const std::string& data) +{ + int l = data.length(); + std::string rv; + rv.reserve(l * 2); + for(int i=0; i < l; i++) + { + unsigned char c = data[i]; + rv.append(1, hextable[c >> 4]); + rv.append(1, hextable[c & 0xF]); + } + return rv; +}