mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
add Hash library currently supports SHA1
This commit is contained in:
26
libraries/Hash/examples/sha1.ino
Normal file
26
libraries/Hash/examples/sha1.ino
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* simple demo to show sha1 calculation
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <hash.h>
|
||||
|
||||
void setup() {
|
||||
Serial.begin(921600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
uint8_t hash[20];
|
||||
const uint8_t test[] = "test";
|
||||
|
||||
sha1((uint8_t *)&test[0], sizeof(test)-1, &hash[0]);
|
||||
|
||||
// SHA1: A94A8FE5CCB19BA61C4C0873D391E987982FBBD3
|
||||
Serial.print("SHA1:");
|
||||
for(uint16_t i = 0; i < 20; i++) {
|
||||
Serial.printf("%02X", hash[i]);
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
Reference in New Issue
Block a user