equal
deleted
inserted
replaced
3 * Copyright (C) 2008 Markus Broeker |
3 * Copyright (C) 2008 Markus Broeker |
4 */ |
4 */ |
5 |
5 |
6 #include <stdio.h> |
6 #include <stdio.h> |
7 #include <stdlib.h> |
7 #include <stdlib.h> |
8 #include <string.h> |
8 #include <time.h> |
|
9 #include <crypt.h> |
|
10 |
|
11 #define GETRANDOM(max) ('a'+(int)((float)max*rand()/RAND_MAX+1.0)) |
9 |
12 |
10 int main (int argc, char **argv) |
13 int main (int argc, char **argv) |
11 { |
14 { |
12 char *data; |
15 char salt[20] = { 0 }; |
13 |
|
14 int i; |
|
15 |
16 |
16 if (argc != 2) { |
17 if (argc != 2) { |
17 printf ("Usage: %s <str>\n", argv[0]); |
18 printf ("Usage: %s <plaintext>\n", argv[0]); |
18 return EXIT_SUCCESS; |
19 return EXIT_FAILURE; |
19 } |
20 } |
20 |
21 |
21 /* |
22 srand (time (NULL)); |
22 * Its already allocated |
|
23 */ |
|
24 data = argv[1]; |
|
25 |
23 |
26 for (i = 0; data[i]; i++) |
24 sprintf (salt, "$1$%c%c", GETRANDOM (26), GETRANDOM (26)); |
27 data[i] = data[i] + 1; |
|
28 |
25 |
29 printf ("EnCrypted Data: %s\n", data); |
26 printf ("%s\n", crypt (argv[1], salt)); |
30 |
|
31 for (i = 0; data[i]; i++) |
|
32 data[i] = data[i] - 1; |
|
33 |
|
34 printf ("DeCrypted Data: %s\n", data); |
|
35 |
|
36 return EXIT_SUCCESS; |
27 return EXIT_SUCCESS; |
37 } |
28 } |