Hallo,
ich würde gerne mit dem Arduino einen MD5-Hash erzeugen.
Dazu habe verwende ich folgende Libary:
https://github.com/tzikis/ArduinoMD5/
Der Besipielcode funktioniert auch ohne Probleme wenn man die zu
verschlüsselnden Werte vorher im Code definiert. Hier ein Beispiel:
1 | void setup()
|
2 | {
|
3 | //initialize serial
|
4 | Serial.begin(9600);
|
5 | //generate the MD5 hash for our string
|
6 | unsigned char* hash=MD5::make_hash("123");
|
7 | //generate the digest (hex encoding) of our hash
|
8 | char *md5str = MD5::make_digest(hash, 16);
|
9 | free(hash);
|
10 | //print it on our serial monitor
|
11 | Serial.println(md5str);
|
12 | //Give the Memory back to the System if you run the md5 Hash generation in a loop
|
13 | free(md5str);
|
14 | }
|
Wenn ich allerdings eine Variable statt "123" einfüge, gibt es einige
Fehler des Compilers.
1 | int test=123;
|
2 |
|
3 |
|
4 | void setup()
|
5 | {
|
6 | //initialize serial
|
7 | Serial.begin(9600);
|
8 | //generate the MD5 hash for our string
|
9 | unsigned char* hash=MD5::make_hash(test);
|
10 | //generate the digest (hex encoding) of our hash
|
11 | char *md5str = MD5::make_digest(hash, 16);
|
12 | free(hash);
|
13 | //print it on our serial monitor
|
14 | Serial.println(md5str);
|
15 | //Give the Memory back to the System if you run the md5 Hash generation in a loop
|
16 | free(md5str);
|
17 | }
|
Fehler:
1 |
|
2 | Arduino: 1.5.8 (Linux), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
|
3 |
|
4 | Arduino-Hashing1.ino: In function 'void setup()':
|
5 | Arduino-Hashing1.ino:19:42: error: invalid conversion from 'int' to 'char*' [-fpermissive]
|
6 | In file included from Arduino-Hashing1.ino:2:0:
|
7 | /home/eizi/Arduino/libraries/md5/MD5.h:43:24: error: initializing argument 1 of 'static unsigned char* MD5::make_hash(char*)' [-fpermissive]
|
8 | static unsigned char* make_hash(char *arg);
|
9 |
|
10 |
|
11 | ^
|
12 | Error compiling.
|
13 |
|
14 | This report would have more information with
|
15 | "Show verbose output during compilation"
|
16 | enabled in File > Preferences.
|
Auch wenn ich die Variable als char definiere klappt es nicht. Wäre toll
wenn mir jemand erklären könnte woran es liegt..