From 42562013b5257e9ca650061df549f7f21739f3c0 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Mon, 2 Sep 2024 15:02:58 +0200 Subject: [PATCH] proccessing password hash in client send loop --- src/chat/main/client.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/chat/main/client.c b/src/chat/main/client.c index 824448c..2edfb97 100644 --- a/src/chat/main/client.c +++ b/src/chat/main/client.c @@ -260,7 +260,23 @@ int main(void) } } else { - why2_send_socket(line, NULL, listen_socket); //NULL IS SENT BECAUSE IT IS USELESS TO SEND USER FROM CLIENT - SERVER WON'T USE IT + if (__why2_get_asking_password()) + { + //REMOVE \n AT THE END OF line + line[strlen(line) - 1] = '\0'; + + char *hash = why2_sha256(line); //HASHISH + + why2_send_socket(hash, NULL, listen_socket); //SEND BUT HASHED + + //DEALLOCATION + why2_deallocate(hash); + __why2_set_asking_password(0); + } else + { + why2_send_socket(line, NULL, listen_socket); //NULL IS SENT BECAUSE IT IS USELESS TO SEND USER FROM CLIENT - SERVER WON'T USE IT + } + free(line); } }