44
55/**
66 * f4 - finds the biggest number
7- *
87 * @usrn: username
98 * @len: length of username
9+ *
1010 * Return: the biggest number
1111 */
1212int f4 (char * usrn , int len )
@@ -17,34 +17,34 @@ int f4(char *usrn, int len)
1717
1818 ch = * usrn ;
1919 vch = 0 ;
20-
20+ /* Find the biggest ASCII value from the username */
2121 while (vch < len )
2222 {
2323 if (ch < usrn [vch ])
2424 ch = usrn [vch ];
2525 vch += 1 ;
2626 }
27-
27+ /* Generate a random number using the biggest ASCII value */
2828 srand (ch ^ 14 );
2929 rand_num = rand ();
3030
3131 return (rand_num & 63 );
3232}
3333
3434/**
35- * f5 - multiplies each char of username
36- *
35+ * f5 - Multiply each character's ASCII value in the username.
3736 * @usrn: username
3837 * @len: length of username
39- * Return: multiplied char
38+ *
39+ * Return: Multiplied ASCII value.
4040 */
4141int f5 (char * usrn , int len )
4242{
4343 int ch ;
4444 int vch ;
4545
4646 ch = vch = 0 ;
47-
47+ /* Multiply each character's ASCII value in the username */
4848 while (vch < len )
4949 {
5050 ch = ch + usrn [vch ] * usrn [vch ];
@@ -55,18 +55,18 @@ int f5(char *usrn, int len)
5555}
5656
5757/**
58- * f6 - generates a random char
58+ * f6 - Generate a random character based on the username.
59+ * @usrn: Username
5960 *
60- * @usrn: username
61- * Return: a random char
61+ * Return: Random character
6262 */
6363int f6 (char * usrn )
6464{
6565 int ch ;
6666 int vch ;
6767
6868 ch = vch = 0 ;
69-
69+ /* Generate a random character based on the username */
7070 while (vch < * usrn )
7171 {
7272 ch = rand ();
@@ -78,9 +78,9 @@ int f6(char *usrn)
7878
7979/**
8080 * main - Entry point
81+ * @argc: Number of command-line arguments
82+ * @argv: Array of command-line arguments
8183 *
82- * @argc: arguments count
83- * @argv: arguments vector
8484 * Return: Always 0
8585 */
8686int main (int argc , char * * argv )
@@ -93,19 +93,20 @@ int main(int argc, char **argv)
9393 0x723161513346655a , 0x6b756f494b646850 };
9494 (void ) argc ;
9595
96+ /* Calculate the length of the username */
9697 for (len = 0 ; argv [1 ][len ]; len ++ )
9798 ;
98- /* ----------- f1 ----------- */
99+ /* f1: Calculate the first character of the key */
99100 keygen [0 ] = ((char * )alph )[(len ^ 59 ) & 63 ];
100- /* ----------- f2 ----------- */
101+ /* f2: Calculate the second character of the key */
101102 ch = vch = 0 ;
102103 while (vch < len )
103104 {
104105 ch = ch + argv [1 ][vch ];
105106 vch = vch + 1 ;
106107 }
107108 keygen [1 ] = ((char * )alph )[(ch ^ 79 ) & 63 ];
108- /* ----------- f3 ----------- */
109+ /* f3: Calculate the third character of the key */
109110 ch = 1 ;
110111 vch = 0 ;
111112 while (vch < len )
@@ -114,12 +115,13 @@ int main(int argc, char **argv)
114115 vch = vch + 1 ;
115116 }
116117 keygen [2 ] = ((char * )alph )[(ch ^ 85 ) & 63 ];
117- /* ----------- f4 ----------- */
118+ /* f4: Calculate the fourth character of the key */
118119 keygen [3 ] = ((char * )alph )[f4 (argv [1 ], len )];
119- /* ----------- f5 ----------- */
120+ /* f5: Calculate the fifth character of the key */
120121 keygen [4 ] = ((char * )alph )[f5 (argv [1 ], len )];
121- /* ----------- f6 ----------- */
122+ /* f6: Calculate the sixth character of the key */
122123 keygen [5 ] = ((char * )alph )[f6 (argv [1 ])];
124+ /* Null-terminate the keygen array */
123125 keygen [6 ] = '\0' ;
124126 for (ch = 0 ; keygen [ch ]; ch ++ )
125127 printf ("%c" , keygen [ch ]);
0 commit comments