mirror of
https://github.com/esphome/esphome.git
synced 2026-02-06 15:59:40 -07:00
35 lines
1.1 KiB
YAML
35 lines
1.1 KiB
YAML
esphome:
|
|
on_boot:
|
|
- lambda: |-
|
|
// Test HMAC-MD5 functionality
|
|
#ifdef USE_MD5
|
|
using esphome::hmac_md5::HmacMD5;
|
|
HmacMD5 hmac;
|
|
|
|
// Test with key "key" and message "The quick brown fox jumps over the lazy dog"
|
|
const char* key = "key";
|
|
const char* message = "The quick brown fox jumps over the lazy dog";
|
|
|
|
hmac.init(key, strlen(key));
|
|
hmac.add(message, strlen(message));
|
|
hmac.calculate();
|
|
|
|
char hex_output[33];
|
|
hmac.get_hex(hex_output);
|
|
hex_output[32] = '\0';
|
|
|
|
ESP_LOGD("HMAC_MD5", "HMAC-MD5('%s', '%s') = %s", key, message, hex_output);
|
|
|
|
// Expected: 80070713463e7749b90c2dc24911e275
|
|
const char* expected = "80070713463e7749b90c2dc24911e275";
|
|
if (strcmp(hex_output, expected) == 0) {
|
|
ESP_LOGI("HMAC_MD5", "Test PASSED");
|
|
} else {
|
|
ESP_LOGE("HMAC_MD5", "Test FAILED. Expected %s", expected);
|
|
}
|
|
#else
|
|
ESP_LOGW("HMAC_MD5", "HMAC-MD5 not available on this platform");
|
|
#endif
|
|
|
|
hmac_md5:
|