crypt.c
changeset 56 966ad681f25d
parent 32 9b56360ec64e
child 74 829976007e62
equal deleted inserted replaced
55:2a20d0184041 56:966ad681f25d
    10 
    10 
    11 #define GETRANDOM(max) ('a'+(int)((float)max*rand()/RAND_MAX+1.0))
    11 #define GETRANDOM(max) ('a'+(int)((float)max*rand()/RAND_MAX+1.0))
    12 
    12 
    13 int main (int argc, char **argv)
    13 int main (int argc, char **argv)
    14 {
    14 {
    15     char salt[20] = { 0 };
    15     char salt[12] = { 0 };
    16 
    16 
    17     if (argc != 2) {
    17     if (argc != 2) {
    18         printf ("Usage: %s <plaintext>\n", argv[0]);
    18         printf ("Usage: %s <plaintext>\n", argv[0]);
    19         return EXIT_FAILURE;
    19         return EXIT_FAILURE;
    20     }
    20     }
    21 
    21 
    22     srand (time (NULL));
    22     srand (time (NULL));
    23 
    23 
    24     sprintf (salt, "$1$%c%c", GETRANDOM (26), GETRANDOM (26));
    24     sprintf (salt, "$1$%c%c%c%c%c%c%c%c",
       
    25              GETRANDOM (26), GETRANDOM (26),
       
    26              GETRANDOM (26), GETRANDOM (26), GETRANDOM (26), GETRANDOM (26), GETRANDOM (26), GETRANDOM (26));
    25 
    27 
    26     printf ("%s\n", crypt (argv[1], salt));
    28     printf ("%s\n", crypt (argv[1], salt));
    27     return EXIT_SUCCESS;
    29     return EXIT_SUCCESS;
    28 }
    30 }