home *** CD-ROM | disk | FTP | other *** search
- /*
- * Received: by kropotkin.gnu.ai.mit.edu (15.11/4.0)
- * id <AA11421@kropotkin.gnu.ai.mit.edu>; Sun, 7 Jul 91 19:20:37 edt
- * Date: Sun, 7 Jul 91 19:20:37 edt
- * Message-Id: <9107072320.AA11421@kropotkin.gnu.ai.mit.edu>
- * To: EDDIE.MIT.EDU!bloom-beacon!spdcc!merk!works!LC717@EDDIE.MIT.EDU
- * Subject: Cyphertext w/o Un*x
- * Cc: tami@gnu.ai.mit.edu
- *
- * MAKEPASS.C - Written 12-Dec-90 by Noah Friedman (friedman@ai.mit.edu)
- *
- * Usage: makepass [password]
- *
- * To compile, type "cc -o makepass makepass.c"
- *
- * This program is public domain.
- */
-
- #include <stdio.h>
-
-
-
- /*
- * If your compiler claims the file string.h cannot be found, edit this
- * program and replace <string.h> with <strings.h>
- */
- #include <string.h>
-
- char *xmalloc();
- char *makesalt();
- char *crypt();
-
- main(argc, argv)
- int argc;
- char **argv;
- {
- char *plain, *salt, *result;
- register int len, i;
-
- if (argc != 2) usage(argv[0]);
-
- len = strlen(argv[1]);
-
-
- plain = xmalloc(len + 1);
- strcpy(plain, argv[1]);
- for (i = 0; i < len; i++) argv[1][i] = '\0';
-
- salt = makesalt();
- result = crypt(plain, salt);
-
- puts(result);
- }
-
- char *xmalloc(n)
- {
- char *s;
- char *malloc();
-
- s = malloc(n * sizeof(char));
- if (s == NULL)
- {
- fprintf(stderr, "malloc: Not enough memory.\n", s);
- exit(1);
- }
-
-
- return s;
- }
-
- char *makesalt()
- {
- static char salt[3];
- char ch1, ch2;
-
- srand(getpid() % 32767);
-
- ch1 = ( rand() % 2 == 0 ) ? 'A' : 'a';
- ch2 = ( rand() % 2 == 0 ) ? 'A' : 'a';
-
- salt[0] = ((unsigned char) rand() % 26) + ch1;
- salt[1] = ((unsigned char) rand() % 26) + ch2;
- salt[2] = '\0';
-
- return salt;
- }
-
- usage(s)
-
-
- char *s;
- {
- fprintf(stderr, "Usage: %s [password]\n", s);
- exit(1);
- }
-