author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Thu, 16 Apr 2009 12:50:39 +0200 | |
changeset 70 | ded389a5dc2a |
parent 56 | 966ad681f25d |
child 74 | 829976007e62 |
permissions | -rw-r--r-- |
0 | 1 |
/** |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
8
diff
changeset
|
2 |
* test/demos/crypt.c |
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 |
||
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 |
} |