comparison quickrypt.c @ 0:bd412f63ce0d

Put this project under version control, finally.
author John "Elwin" Edwards <elwin@sdf.org>
date Sun, 06 May 2012 08:45:40 -0700
parents
children 9bef0941c6dd
comparison
equal deleted inserted replaced
-1:000000000000 0:bd412f63ce0d
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <crypt.h>
5
6 int main(int argc, char *argv[]) {
7 char clear[32], enc[120], *ptr;
8 fgets(&clear, 32, stdin);
9 if (!(ptr = strchr(&clear, '\n')))
10 return 1;
11 else
12 *ptr = '\0';
13 fgets(&enc, 120, stdin);
14 if (!(ptr = strchr(&enc, '\n')))
15 return 1;
16 else
17 *ptr = '\0';
18 ptr = crypt(clear, enc);
19 if (!strcmp(argv[argc - 1], "-s")) {
20 /* Option -s for "show": output the encrypted version. */
21 printf("%s\n", ptr);
22 return 0;
23 }
24 /* Otherwise this is a check. */
25 else if (!strcmp(ptr, enc))
26 return 0;
27 return 1;
28 }