-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmd5read.c
47 lines (43 loc) · 1.46 KB
/
md5read.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* md5read.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vdenysov <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/22 12:57:30 by vdenysov #+# #+# */
/* Updated: 2018/10/22 12:57:32 by vdenysov ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_md5.h"
void md5read(t_md5 *md, char *input, int fd, t_flags *flag)
{
int ret;
char buf[64];
md5init(md, "");
md->mdname = input;
while ((ret = read(fd, buf, 64)) > 0)
{
buf[ret] = '\0';
md->input = buf;
md->inputlen = ret;
md->len += ret;
if (ret < 64 && ret > 55)
{
md5update(md, buf);
md->inputlen = 0;
}
md5update(md, buf);
}
md->inputlen = 0;
if (md->len == 64 || md->len == 0)
md5update(md, buf);
md5print(md, flag);
}
void md5string(t_md5 *md, char *av, t_flags *flag)
{
md5init(md, av);
md->isstr = 1;
md5loop(md);
md5print(md, flag);
}