gra-projekt/Implementierung/src/md2.c

28 lines
767 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-07-15 11:30:19 +02:00
#include "../lib/md2_impls/md2_1.h"
#include "../lib/md2_impls/md2_2.h"
2022-07-15 00:01:35 +02:00
#include "../lib/md2_impls/md2_3.h"
#include "../lib/md2_impls/md2_reference/md2_reference.h"
2022-06-29 15:53:46 +02:00
2022-07-04 18:02:34 +02:00
md2_hash_func md2_hash;
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-20 23:23:18 +02:00
static md2_hash_func md2_implementations[] = {
md2_hash_0, md2_hash_1, md2_hash_2, md2_hash_3, md2_hash_ref};
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) {
2022-07-20 23:23:18 +02:00
if (i < 0 || i > 4) return false;
md2_hash = md2_implementations[i];
return true;
2022-06-29 15:41:56 +02:00
}