implemented why2_list_push_at in encrypter paddding

This commit is contained in:
Václav Šmejkal 2024-11-21 17:13:16 +01:00
parent 98cc5b83b8
commit 38f814ac9c
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -103,28 +103,11 @@ why2_output_flags why2_encrypt_text(char *text, char *key)
why2_random(&random_char, sizeof(random_char)); //GENERATE COMPLETELY RANDOM CHARACTER why2_random(&random_char, sizeof(random_char)); //GENERATE COMPLETELY RANDOM CHARACTER
//INSERT RANDOM VALUE //INSERT RANDOM VALUE
why2_node_t *inserted_node = why2_malloc(sizeof(why2_node_t)); //ALLOCATE NODE why2_list_push_at(&split_text, random_position, &random_char, sizeof(random_char));
inserted_node -> value = why2_malloc(sizeof(random_char)); //ALLOCATE VALUE
memcpy(inserted_node -> value, &random_char, sizeof(random_char)); //INSERT DATA
//INSERT INTO LIST
if (random_position != 0) //SHOULDN'T BE FIRST
{
why2_node_t *node_before = split_text.head;
for (unsigned long j = 0; j < random_position - 1; j++) node_before = node_before -> next; //SCROLL TO THE POSITION
inserted_node -> next = node_before -> next; //SEW THE LIST BACK
node_before -> next = inserted_node;
} else //ADD BEFORE THE WHOLE LIST
{
inserted_node -> next = split_text.head;
split_text.head = inserted_node;
}
} }
//PUT PADDED TEXT INTO text_new //PUT PADDED TEXT INTO text_new
text_new = why2_malloc(why2_list_get_size(&split_text) + 1); text_new = why2_calloc(why2_list_get_size(&split_text) + 1, sizeof(char));
why2_node_t *buffer = split_text.head; why2_node_t *buffer = split_text.head;
why2_node_t *buffer_2; why2_node_t *buffer_2;
unsigned long index_buffer = 0; unsigned long index_buffer = 0;