1 /*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8 #ifndef lint
9 static char copyright[] =
10 "@(#) Copyright (c) 1990, 1993\n\
11 The Regents of the University of California. All rights reserved.\n";
12 #endif /* not lint */
13
14 #ifndef lint
15 static char sccsid[] = "@(#)makekey.c 8.1 (Berkeley) 06/04/93";
16 #endif /* not lint */
17
18 #include <sys/types.h>
19
20 #include <err.h>
21 #include <errno.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <unistd.h>
26
27 static void get __P((char *, int));
28
29 int
main()30 main()
31 {
32 int len;
33 char *r, key[9], salt[3];
34
35 get(key, sizeof(key) - 1);
36 get(salt, sizeof(salt) - 1);
37 len = strlen(r = crypt(key, salt));
38 if (write(STDOUT_FILENO, r, len) != len)
39 err(1, "stdout");
40 exit(0);
41 }
42
43 static void
get(bp,len)44 get(bp, len)
45 char *bp;
46 register int len;
47 {
48 register int nr;
49
50 bp[len] = '\0';
51 if ((nr = read(STDIN_FILENO, bp, len)) == len)
52 return;
53 if (nr >= 0)
54 errno = EFTYPE;
55 err(1, "stdin");
56 }
57