mirror of
https://github.com/esphome/esphome.git
synced 2025-10-07 20:33:47 +01:00
cleanup
This commit is contained in:
@@ -44,10 +44,8 @@ void MD5Digest::get_bytes(uint8_t *output) { memcpy(output, this->digest_, 16);
|
||||
void MD5Digest::get_hex(char *output) {
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
uint8_t byte = this->digest_[i];
|
||||
uint8_t high = byte >> 4;
|
||||
uint8_t low = byte & 0x0F;
|
||||
output[i * 2] = high < 10 ? '0' + high : 'a' + (high - 10);
|
||||
output[i * 2 + 1] = low < 10 ? '0' + low : 'a' + (low - 10);
|
||||
output[i * 2] = format_hex_char(byte >> 4);
|
||||
output[i * 2 + 1] = format_hex_char(byte & 0x0F);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -258,7 +258,6 @@ std::string format_mac_address_pretty(const uint8_t *mac) {
|
||||
return str_snprintf("%02X:%02X:%02X:%02X:%02X:%02X", 17, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
}
|
||||
|
||||
static char format_hex_char(uint8_t v) { return v >= 10 ? 'a' + (v - 10) : '0' + v; }
|
||||
std::string format_hex(const uint8_t *data, size_t length) {
|
||||
std::string ret;
|
||||
ret.resize(length * 2);
|
||||
|
@@ -380,6 +380,9 @@ template<typename T, enable_if_t<std::is_unsigned<T>::value, int> = 0> optional<
|
||||
return parse_hex<T>(str.c_str(), str.length());
|
||||
}
|
||||
|
||||
/// Convert a nibble (0-15) to lowercase hex char
|
||||
inline char format_hex_char(uint8_t v) { return v >= 10 ? 'a' + (v - 10) : '0' + v; }
|
||||
|
||||
/// Format the six-byte array \p mac into a MAC address.
|
||||
std::string format_mac_address_pretty(const uint8_t mac[6]);
|
||||
/// Format the byte array \p data of length \p len in lowercased hex.
|
||||
|
Reference in New Issue
Block a user