Skip to content

Commit 9f6d5fb

Browse files
author
Louise P
committed
Sha1 finish
1 parent dcff9a5 commit 9f6d5fb

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

srcs/hash/sha1/sha1.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: cpieri <cpieri@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2019/12/30 08:04:36 by cpieri #+# #+# */
9-
/* Updated: 2019/12/30 12:03:02 by cpieri ### ########.fr */
9+
/* Updated: 2019/12/31 07:58:25 by cpieri ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -45,7 +45,7 @@ static void calc_sha1(t_sha1 *e)
4545
tool = func_sha1_f(e->b, e->c, e->d);
4646
else if (i >= 20 && i <= 39)
4747
tool = func_sha1_g(e->b, e->c, e->d);
48-
else if (i >= 40 && i >= 59)
48+
else if (i >= 40 && i <= 59)
4949
tool = func_sha1_h(e->b, e->c, e->d);
5050
else if (i >= 60 && i <= 79)
5151
tool = func_sha1_i(e->b, e->c, e->d);
@@ -86,7 +86,7 @@ void *sha1(void *data, size_t len_data)
8686
t_hash *sum;
8787

8888
e = (t_sha1){.h0 = SHA1_H0, .h1 = SHA1_H1, .h2 = SHA1_H2, .h3 = SHA1_H3,
89-
.h4 = SHA1_H4};
89+
.h4 = SHA1_H4, .w = NULL};
9090
padding_sha1(&(e.p), data, len_data);
9191
while (e.p.offest < e.p.new_len)
9292
{

srcs/hash/sha1/sha1_utils.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
/* By: cpieri <cpieri@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2019/12/30 08:42:25 by cpieri #+# #+# */
9-
/* Updated: 2019/12/30 11:49:53 by cpieri ### ########.fr */
9+
/* Updated: 2019/12/31 07:58:34 by cpieri ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#include "hash/sha1.h"
14+
#include <stdio.h>
1415

1516
t_sha1_utils func_sha1_f(uint32_t b, uint32_t c, uint32_t d)
1617
{
@@ -20,6 +21,7 @@ t_sha1_utils func_sha1_f(uint32_t b, uint32_t c, uint32_t d)
2021
ret.k = 0x5a827999;
2122
return (ret);
2223
}
24+
2325
t_sha1_utils func_sha1_g(uint32_t b, uint32_t c, uint32_t d)
2426
{
2527
t_sha1_utils ret;
@@ -28,6 +30,7 @@ t_sha1_utils func_sha1_g(uint32_t b, uint32_t c, uint32_t d)
2830
ret.k = 0x6ed9eba1;
2931
return (ret);
3032
}
33+
3134
t_sha1_utils func_sha1_h(uint32_t b, uint32_t c, uint32_t d)
3235
{
3336
t_sha1_utils ret;
@@ -36,6 +39,7 @@ t_sha1_utils func_sha1_h(uint32_t b, uint32_t c, uint32_t d)
3639
ret.k = 0x8f1bbcdc;
3740
return (ret);
3841
}
42+
3943
t_sha1_utils func_sha1_i(uint32_t b, uint32_t c, uint32_t d)
4044
{
4145
t_sha1_utils ret;

0 commit comments

Comments
 (0)