home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / admin / 4882 < prev    next >
Encoding:
Text File  |  1992-09-04  |  2.3 KB  |  70 lines

  1. Xref: sparky comp.unix.admin:4882 comp.unix.ultrix:6699 comp.unix.wizards:3802
  2. Newsgroups: comp.unix.admin,comp.unix.ultrix,comp.unix.wizards
  3. Path: sparky!uunet!sun-barr!cs.utexas.edu!wupost!ukma!psuvax1!news.cc.swarthmore.edu!hirai
  4. From: hirai@cc.swarthmore.edu (Eiji Hirai)
  5. Subject: Re: random passwd generator
  6. Message-ID: <SY2PBNX5@cc.swarthmore.edu>
  7. Sender: news@cc.swarthmore.edu (USENET News System)
  8. Nntp-Posting-Host: gingko
  9. Organization: Information Services, Swarthmore College, Swarthmore, PA, USA
  10. References: <1992Sep4.170148.17469@trentu.ca>
  11. Date: Fri, 4 Sep 1992 18:52:00 GMT
  12. Lines: 56
  13.  
  14. ccksb@blaze.trentu.ca (Ken Brown) writes:
  15. > I'm looking for a program which will generate 'n' number of passwords.
  16.  
  17. How about this minimalist program below.  You give a number as an argument
  18. and it'll give you that many passwords, both in the original form and
  19. encrypted form.  It tries to make the passwords be a pronounce-able word.
  20.  
  21. Hack and enjoy.
  22.  
  23. --
  24. Eiji Hirai <hirai@cc.swarthmore.edu>    :     :    :   :  : :: ::: :::: :::::
  25. Unix Hacker for Swarthmore College      :     :    :   :  : :: ::: :::: :::::
  26. Information Services, Swarthmore, PA, USA.      Copyright 1992 by Eiji Hirai.
  27. I don't speak for Swarthmore College.                    All Rights Reserved.
  28.  
  29. /* generate.c - generates encrypted strings for random passwords.  -eiji */
  30.  
  31. #include <stdio.h>
  32. #include <time.h>
  33.  
  34. extern char    *crypt();
  35.  
  36. #define SALT    ".."
  37. #define LETTERS    26    /* number of letters in the English alphabet */
  38.  
  39. void    main(int argc, char *argv[])
  40. {
  41.     int    howmany, numConsonant, numVowel, count, count2;
  42.     char    password[16], consonant[LETTERS], vowel[LETTERS];
  43.  
  44.     if (argc != 2) {
  45.         fprintf (stderr, "usage: %s howmany\n", argv[0]);
  46.         exit (1);
  47.     }
  48.  
  49.     howmany = atoi (argv[1]);
  50.     srandom((int)(time((time_t *)0)));
  51.  
  52.     strcpy (consonant, "bcdfghjklmnpqrstvwxyz");
  53.     strcpy (vowel, "aeiou");
  54.     numConsonant = strlen(consonant);
  55.     numVowel = strlen(vowel);
  56.  
  57.     for (count = 0; count < howmany; count++)
  58.     {
  59.         strcpy (password, "");
  60.         for (count2 = 0; count2 < 8; count2 += 2)
  61.             password[count2] = consonant[random()%numConsonant];
  62.         for (count2 = 1; count2 < 8; count2 += 2)
  63.             password[count2] = vowel[random()%numVowel];
  64.         for (count2 = 0; count2 < 8; count2 ++)
  65.             if (!(random() % 3))
  66.                 password[count2] = password[count2] - 'a' + 'A';
  67.         printf ("%s\t%s\n", password, crypt(password, SALT));
  68.     }
  69. }
  70.