-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssdeep_util.c
47 lines (41 loc) · 1.05 KB
/
ssdeep_util.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
#include <inttypes.h>
#include "fuzzy.h"
char *
fuzzy_hash(char *filename) {
FILE *input;
int i;
char *hash;
hash = (char *)malloc(FUZZY_MAX_RESULT);
if (NULL == hash)
return("malloc oops");
input = fopen(filename, "rb");
if (NULL == input)
return("fopen oops");
i = fuzzy_hash_file(input, hash);
fclose(input);
if (0 == i)
return(hash);
else
return("fuzzy_hash_file oops");
}
char *
fuzzy_hash_data(char *buf, uint32_t buf_len) {
char *hash;
int i;
hash = (char *)malloc(FUZZY_MAX_RESULT);
if (NULL == hash)
return ("malloc oops");
i = fuzzy_hash_buf((unsigned char *)buf, buf_len,hash);
if (0 == i)
return (hash);
else
return ("fuzzy_hash_data oops");
}