1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 14:43:51 +00:00

Add sha256 support (#10882)

This commit is contained in:
J. Nick Koston
2025-09-25 15:53:21 -05:00
committed by GitHub
parent 7af77d0f82
commit 3eb502b328
15 changed files with 277 additions and 46 deletions

View File

@@ -0,0 +1,32 @@
esphome:
on_boot:
- lambda: |-
// Test SHA256 functionality
#ifdef USE_SHA256
using esphome::sha256::SHA256;
SHA256 hasher;
hasher.init();
// Test with "Hello World" - known SHA256
const char* test_string = "Hello World";
hasher.add(test_string, strlen(test_string));
hasher.calculate();
char hex_output[65];
hasher.get_hex(hex_output);
hex_output[64] = '\0';
ESP_LOGD("SHA256", "SHA256('Hello World') = %s", hex_output);
// Expected: a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e
const char* expected = "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e";
if (strcmp(hex_output, expected) == 0) {
ESP_LOGI("SHA256", "Test PASSED");
} else {
ESP_LOGE("SHA256", "Test FAILED. Expected %s", expected);
}
#else
ESP_LOGW("SHA256", "SHA256 not available on this platform");
#endif
sha256:

View File

@@ -0,0 +1 @@
<<: !include common.yaml

View File

@@ -0,0 +1 @@
<<: !include common.yaml

View File

@@ -0,0 +1 @@
<<: !include common.yaml

View File

@@ -0,0 +1 @@
<<: !include common.yaml

View File

@@ -0,0 +1 @@
<<: !include common.yaml