implemented seeded-rand fns in padding code

This commit is contained in:
Václav Šmejkal 2025-01-10 17:56:34 +01:00
parent e363eccc59
commit 023e201ac7
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
2 changed files with 4 additions and 4 deletions

View File

@ -189,13 +189,13 @@ why2_output_flags why2_decrypt_text(char *text, char *key)
} }
//OBTAIN SEED FROM key_new //OBTAIN SEED FROM key_new
srand(why2_sum_segment(key_new)); why2_seed_random(why2_sum_segment(key_new));
//GET RANDOM SEQUENCE USED IN ENCRYPTION //GET RANDOM SEQUENCE USED IN ENCRYPTION
why2_list_t random_sequence = WHY2_LIST_EMPTY; why2_list_t random_sequence = WHY2_LIST_EMPTY;
for (unsigned long i = 0; i < why2_get_flags().padding; i++) for (unsigned long i = 0; i < why2_get_flags().padding; i++)
{ {
int rand_buffer = rand(); int rand_buffer = why2_seeded_random();
why2_list_push(&random_sequence, &rand_buffer, sizeof(int)); //ADD why2_list_push(&random_sequence, &rand_buffer, sizeof(int)); //ADD
} }
why2_list_reverse(&random_sequence, sizeof(int)); //REVERSE why2_list_reverse(&random_sequence, sizeof(int)); //REVERSE

View File

@ -92,12 +92,12 @@ why2_output_flags why2_encrypt_text(char *text, char *key)
} }
//OBTAIN SEED FROM key_new //OBTAIN SEED FROM key_new
srand(why2_sum_segment(key_new)); why2_seed_random(why2_sum_segment(key_new));
//ADD PADDING TO split_text LIST //ADD PADDING TO split_text LIST
for (unsigned long i = 0; i < why2_get_flags().padding; i++) for (unsigned long i = 0; i < why2_get_flags().padding; i++)
{ {
unsigned long random_position = (unsigned long) (rand() % (why2_list_get_size(&split_text))); //GET RANDOM POSITION unsigned long random_position = (unsigned long) (why2_seeded_random() % (why2_list_get_size(&split_text))); //GET RANDOM POSITION
char random_char = 0; char random_char = 0;
for (int j = 0; j < WHY2_PADDING_NONZERO_TRIES && random_char == 0 ; j++) //GET RANDOM (EXCLUDING 0) for (int j = 0; j < WHY2_PADDING_NONZERO_TRIES && random_char == 0 ; j++) //GET RANDOM (EXCLUDING 0)