MCPcopy Create free account
hub / github.com/Heltec-Aaron-Lee/WiFi_Kit_series / getSketchSHA256

Function getSketchSHA256

libraries/HTTPUpdate/src/HTTPUpdate.cpp:161–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161String getSketchSHA256() {
162 const size_t HASH_LEN = 32; // SHA-256 digest length
163
164 uint8_t sha_256[HASH_LEN] = {0};
165
166 // get sha256 digest for running partition
167 if (esp_partition_get_sha256(esp_ota_get_running_partition(), sha_256) == 0) {
168 char buffer[2 * HASH_LEN + 1];
169
170 for (size_t index = 0; index < HASH_LEN; index++) {
171 uint8_t nibble = (sha_256[index] & 0xf0) >> 4;
172 buffer[2 * index] = nibble < 10 ? char(nibble + '0') : char(nibble - 10 + 'A');
173
174 nibble = sha_256[index] & 0x0f;
175 buffer[2 * index + 1] = nibble < 10 ? char(nibble + '0') : char(nibble - 10 + 'A');
176 }
177
178 buffer[2 * HASH_LEN] = '\0';
179
180 return String(buffer);
181 } else {
182
183 return String();
184 }
185}
186
187/**
188 *

Callers 1

handleUpdateMethod · 0.85

Calls 1

StringClass · 0.85

Tested by

no test coverage detected