7 #include "sodium-buffer.hpp"
10 class InvalidHexCharacterException :
public std::invalid_argument
13 explicit InvalidHexCharacterException(
const char* what =
14 "Could not parse non-hex character"
16 std::invalid_argument(what) {}
19 inline unsigned char parseHexChar(
char c) {
20 if (c >=
'0' && c <=
'9') {
22 }
else if (c >=
'a' && c <=
'f') {
23 return 10 + (c -
'a');
24 }
else if (c >=
'A' && c <=
'F') {
25 return 10 + (c -
'A');
27 throw InvalidHexCharacterException();
30 const std::string toHexStr(
const std::vector<unsigned char> bytes);
31 const std::vector<unsigned char> hexStrToByteVector(
const std::string hexStr);
33 inline std::string toUpper(
const std::string& a) {
34 std::string upper = a;
35 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper);