author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Thu, 16 Apr 2009 12:49:11 +0200 | |
changeset 32 | 9b56360ec64e |
parent 27 | 81a574d60c15 |
child 56 | 966ad681f25d |
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 |
{ |
|
32 | 15 |
char salt[20] = { 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 |
|
32 | 24 |
sprintf (salt, "$1$%c%c", GETRANDOM (26), GETRANDOM (26)); |
0 | 25 |
|
32 | 26 |
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
|
27 |
return EXIT_SUCCESS; |
0 | 28 |
} |