28 lines
767 B
C
28 lines
767 B
C
#include "../lib/md2.h"
|
|
|
|
// include all implementations
|
|
#include "../lib/md2_impls/md2_0.h"
|
|
#include "../lib/md2_impls/md2_1.h"
|
|
#include "../lib/md2_impls/md2_2.h"
|
|
#include "../lib/md2_impls/md2_3.h"
|
|
#include "../lib/md2_impls/md2_reference/md2_reference.h"
|
|
|
|
md2_hash_func md2_hash;
|
|
|
|
// The file "testfile" should lead to this hash:
|
|
// fc982e558db259f298b43cd4c1241c66
|
|
|
|
static md2_hash_func md2_implementations[] = {
|
|
md2_hash_0, md2_hash_1, md2_hash_2, md2_hash_3, md2_hash_ref};
|
|
|
|
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]);
|
|
}
|
|
}
|
|
|
|
bool md2_choose_implementation(int i) {
|
|
if (i < 0 || i > 4) return false;
|
|
md2_hash = md2_implementations[i];
|
|
return true;
|
|
} |