2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2018 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2013 Daniel Vassdal <shutter@canternet.org>
6 * Copyright (C) 2013 Attila Molnar <attilamolnar@hush.com>
7 * Copyright (C) 2012 Robby <robby@chatbelgie.be>
8 * Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
9 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
10 * Copyright (C) 2008 Pippijn van Steenhoven <pip88nl@gmail.com>
11 * Copyright (C) 2007, 2010 Craig Edwards <brain@inspircd.org>
12 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
14 * This file is part of InspIRCd. InspIRCd is free software: you can
15 * redistribute it and/or modify it under the terms of the GNU General Public
16 * License as published by the Free Software Foundation, version 2.
18 * This program is distributed in the hope that it will be useful, but WITHOUT
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 /** Sets ret to the formatted string. last is the last parameter before ..., and format is the format in printf-style */
33 #define VAFORMAT(ret, last, format) \
36 va_start(_vaList, last); \
37 ret.assign(InspIRCd::Format(_vaList, format)); \
41 /** Compose a hex string from raw data.
42 * @param raw The raw data to compose hex from (can be NULL if rawsize is 0)
43 * @param rawsize The size of the raw data buffer
44 * @return The hex string
46 CoreExport std::string BinToHex(const void* raw, size_t rawsize);
49 CoreExport std::string BinToBase64(const std::string& data, const char* table = NULL, char pad = 0);
51 CoreExport std::string Base64ToBin(const std::string& data, const char* table = NULL);
53 /** Compose a hex string from the data in a std::string.
54 * @param data The data to compose hex from
55 * @return The hex string.
57 inline std::string BinToHex(const std::string& data)
59 return BinToHex(data.data(), data.size());