home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.admin:4882 comp.unix.ultrix:6699 comp.unix.wizards:3802
- Newsgroups: comp.unix.admin,comp.unix.ultrix,comp.unix.wizards
- Path: sparky!uunet!sun-barr!cs.utexas.edu!wupost!ukma!psuvax1!news.cc.swarthmore.edu!hirai
- From: hirai@cc.swarthmore.edu (Eiji Hirai)
- Subject: Re: random passwd generator
- Message-ID: <SY2PBNX5@cc.swarthmore.edu>
- Sender: news@cc.swarthmore.edu (USENET News System)
- Nntp-Posting-Host: gingko
- Organization: Information Services, Swarthmore College, Swarthmore, PA, USA
- References: <1992Sep4.170148.17469@trentu.ca>
- Date: Fri, 4 Sep 1992 18:52:00 GMT
- Lines: 56
-
- ccksb@blaze.trentu.ca (Ken Brown) writes:
- > I'm looking for a program which will generate 'n' number of passwords.
-
- How about this minimalist program below. You give a number as an argument
- and it'll give you that many passwords, both in the original form and
- encrypted form. It tries to make the passwords be a pronounce-able word.
-
- Hack and enjoy.
-
- --
- Eiji Hirai <hirai@cc.swarthmore.edu> : : : : : :: ::: :::: :::::
- Unix Hacker for Swarthmore College : : : : : :: ::: :::: :::::
- Information Services, Swarthmore, PA, USA. Copyright 1992 by Eiji Hirai.
- I don't speak for Swarthmore College. All Rights Reserved.
-
- /* generate.c - generates encrypted strings for random passwords. -eiji */
-
- #include <stdio.h>
- #include <time.h>
-
- extern char *crypt();
-
- #define SALT ".."
- #define LETTERS 26 /* number of letters in the English alphabet */
-
- void main(int argc, char *argv[])
- {
- int howmany, numConsonant, numVowel, count, count2;
- char password[16], consonant[LETTERS], vowel[LETTERS];
-
- if (argc != 2) {
- fprintf (stderr, "usage: %s howmany\n", argv[0]);
- exit (1);
- }
-
- howmany = atoi (argv[1]);
- srandom((int)(time((time_t *)0)));
-
- strcpy (consonant, "bcdfghjklmnpqrstvwxyz");
- strcpy (vowel, "aeiou");
- numConsonant = strlen(consonant);
- numVowel = strlen(vowel);
-
- for (count = 0; count < howmany; count++)
- {
- strcpy (password, "");
- for (count2 = 0; count2 < 8; count2 += 2)
- password[count2] = consonant[random()%numConsonant];
- for (count2 = 1; count2 < 8; count2 += 2)
- password[count2] = vowel[random()%numVowel];
- for (count2 = 0; count2 < 8; count2 ++)
- if (!(random() % 3))
- password[count2] = password[count2] - 'a' + 'A';
- printf ("%s\t%s\n", password, crypt(password, SALT));
- }
- }
-