author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Tue, 01 Jun 2010 13:13:34 +0200 | |
changeset 128 | efa226a4801e |
parent 119 | 305d2ca32936 |
child 131 | b5ad49852adc |
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> |
119
305d2ca32936
crypt.h seems to be broken on many systems.
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
9 |
#include <unistd.h> |
305d2ca32936
crypt.h seems to be broken on many systems.
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
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 |
} |