diff --git a/esphome/components/sha256/sha256.cpp b/esphome/components/sha256/sha256.cpp index 699579251e..94f623f2fa 100644 --- a/esphome/components/sha256/sha256.cpp +++ b/esphome/components/sha256/sha256.cpp @@ -98,7 +98,9 @@ void SHA256::get_hex(char *output) { return; } for (size_t i = 0; i < 32; i++) { - sprintf(output + i * 2, "%02x", this->ctx_->hash[i]); + uint8_t byte = this->ctx_->hash[i]; + output[i * 2] = format_hex_char(byte >> 4); + output[i * 2 + 1] = format_hex_char(byte & 0x0F); } }