gra-projekt/Implementierung/src/md2.c

28 lines
580 B
C
Raw Normal View History

2022-06-29 15:41:56 +02:00
#include "../lib/md2.h"
2022-06-29 10:58:49 +02:00
2022-07-04 18:02:34 +02:00
// include all implementations
#include "../lib/md2_impls/md2_0.h"
2022-06-29 15:53:46 +02:00
2022-07-04 18:02:34 +02:00
md2_hash_func md2_hash;
md2_checksum_func md2_checksum;
2022-06-29 15:41:56 +02:00
2022-07-04 18:02:34 +02:00
// The file "testfile" should lead to this hash:
// fc982e558db259f298b43cd4c1241c66
2022-06-29 15:53:46 +02:00
2022-07-04 18:02:34 +02:00
void md2_encode_hash(uint8_t hash[16], char* string_hash) {
for (int i = 0; i < 16; i++) {
sprintf(string_hash + (2 * i), "%02x", hash[i]);
2022-06-29 15:53:46 +02:00
}
}
2022-06-29 10:58:49 +02:00
2022-07-04 18:02:34 +02:00
bool md2_choose_implementation(int i) {
switch (i) {
case 0:
md2_hash = md2_hash_0;
2022-07-04 18:17:03 +02:00
md2_checksum = md2_checksum_0;
2022-07-04 18:02:34 +02:00
return true;
2022-06-29 16:07:05 +02:00
2022-07-04 18:02:34 +02:00
default:
return false;
2022-06-29 19:03:12 +02:00
}
2022-06-29 15:41:56 +02:00
}