diff --git libtransmission/crypto-utils.cc libtransmission/crypto-utils.cc index a77e2c9..aaea1f1 100644 --- libtransmission/crypto-utils.cc +++ libtransmission/crypto-utils.cc @@ -171,6 +171,11 @@ constexpr void tr_binary_to_hex(void const* vinput, void* voutput, size_t byte_l } } +// Custom constexpr function to convert a character to lowercase +constexpr char toLower(char c) { + return (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c; +} + constexpr void tr_hex_to_binary(char const* input, void* voutput, size_t byte_length) { auto constexpr Hex = "0123456789abcdef"sv; @@ -179,9 +184,9 @@ constexpr void tr_hex_to_binary(char const* input, void* voutput, size_t byte_le for (size_t i = 0; i < byte_length; ++i) { - auto const upper_nibble = Hex.find(std::tolower(*input++)); - auto const lower_nibble = Hex.find(std::tolower(*input++)); - *output++ = (uint8_t)((upper_nibble << 4) | lower_nibble); + auto const upper_nibble = Hex.find(toLower(*input++)); + auto const lower_nibble = Hex.find(toLower(*input++)); + *output++ = static_cast((upper_nibble << 4) | lower_nibble); } }