Open dlb-David opened 9 months ago
void setup(){ Serial.begin(115200); char key = "secretKey"; char payload = "Hello HMAC SHA 256!"; byte hmacResult[32]; mbedtls_md_context_t ctx; mbedtls_md_type_t md_type = MBEDTLS_MD_SHA256; const size_t payloadLength = strlen(payload); const size_t keyLength = strlen(key); mbedtls_md_init(&ctx); mbedtls_md_setup(&ctx, mbedtls_md_info_from_type(md_type), 1); mbedtls_md_hmac_starts(&ctx, (const unsigned char ) key, keyLength); mbedtls_md_hmac_update(&ctx, (const unsigned char ) payload, payloadLength); mbedtls_md_hmac_finish(&ctx, hmacResult); mbedtls_md_free(&ctx);
Serial.print("Hash: ");
for(int i= 0; i< sizeof(hmacResult); i++){ char str[3]; sprintf(str, "%02x", (int)hmacResult[i]); Serial.print(str); }} void loop(){} -- | --
<?php echo hash_hmac('sha256', 'The quick brown fox jumped over the lazy dog.', 'secret'); ?>
L'exemple ci-dessus va afficher :
9c5c42422b03f0ee32949920649445e417b2c634050833c5165704b825c2a53b
Fingerprint not working jet