author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Sat, 15 Aug 2009 23:05:54 +0200 | |
changeset 106 | a540a842ddef |
parent 77 | 49e0babccb23 |
child 119 | 305d2ca32936 |
permissions | -rw-r--r-- |
0 | 1 |
/** |
77 | 2 |
* crypt.c |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
8
diff
changeset
|
3 |
* Copyright (C) 2008 Markus Broeker |
0 | 4 |
*/ |
5 |
||
6 |
#include <stdio.h> |
|
7 |
#include <stdlib.h> |
|
32 | 8 |
#include <time.h> |
9 |
#include <crypt.h> |
|
10 |
||
74
829976007e62
getrandom macro fixed
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
56
diff
changeset
|
11 |
#define GETRANDOM(max) ('a'+(int)((float)(max)*rand()/RAND_MAX+1.0)) |
0 | 12 |
|
13 |
int main (int argc, char **argv) |
|
14 |
{ |
|
56 | 15 |
char salt[12] = { 0 }; |
0 | 16 |
|
17 |
if (argc != 2) { |
|
32 | 18 |
printf ("Usage: %s <plaintext>\n", argv[0]); |
19 |
return EXIT_FAILURE; |
|
0 | 20 |
} |
21 |
||
32 | 22 |
srand (time (NULL)); |
0 | 23 |
|
56 | 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)); |
|
0 | 27 |
|
32 | 28 |
printf ("%s\n", crypt (argv[1], salt)); |
8
96d16dfe787a
We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
29 |
return EXIT_SUCCESS; |
0 | 30 |
} |