home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #23 / NN_1992_23.iso / spool / sci / crypt / 3806 < prev    next >
Encoding:
Text File  |  1992-10-15  |  2.4 KB  |  73 lines

  1. Path: sparky!uunet!destroyer!gatech!concert!duke!srt
  2. From: srt@duke.cs.duke.edu (Stephen R. Tate)
  3. Newsgroups: sci.crypt
  4. Subject: Re: DES Encryption/ Encrypting more than once.
  5. Message-ID: <719175856@pike.cs.duke.edu>
  6. Date: 15 Oct 92 19:04:17 GMT
  7. References: <wa6JsB7w165w@works.uucp> <1992Oct13.174505.24230@b11.b11.ingr.com> <1992Oct15.012933.20350@ringer.cs.utsa.edu>
  8. Organization: Duke University Computer Science Dept.; Durham, N.C.
  9. Lines: 62
  10.  
  11. In article <1992Oct15.012933.20350@ringer.cs.utsa.edu> cbarkley@alex (The DarkMage) writes:
  12. >Can anyone send me the PRECISE algorithm used to build a UNIX
  13. >password for the password file?  Source code for it would be
  14. >even nicer.
  15.  
  16. Geez... can't anyone read a man page any more?  The following program
  17. was trivial to throw together.  It should compile on any UNIX system ---
  18. you don't need to have the source code for the encryption algorithm,
  19. since it is part of the standard C library (on UNIX systems, anyway).
  20.  
  21. There is a very weak attempt at producing "random looking" salts for
  22. the passwords.  Due to this, even if you run the program twice on the
  23. same password, it should give you two different encrypted versions (this
  24. is fine).  
  25.  
  26. Use of the program is very simple.  If you compile the program to
  27. an executable named "encpasswd", then "encpasswd foo" gives you an
  28. encrypted form for password "foo".
  29.  
  30. You may send my consulting fee to the address below. :-)
  31.  
  32.                     Steve Tate
  33.  
  34. ===========================================================================
  35.  
  36. #include <stdio.h>
  37.  
  38. char *crypt();
  39.  
  40. char saltchars[] = 
  41.        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./";
  42.  
  43. int main(argc, argv)
  44. int argc;
  45. char *argv[];
  46. {
  47.     char salt[3];
  48.     int saltint;
  49.  
  50.     if (argc < 2) {
  51.     fprintf(stderr, "Usage: %s <password>\n", argv[0]);
  52.         exit(1);
  53.     }
  54.  
  55.     saltint = getpid() % 4099;
  56.     saltint = (saltint * 2040) % 4099;
  57.     salt[0] = saltchars[ saltint&0x3f ];
  58.     salt[1] = saltchars[ (saltint>>6)&0x3f ];
  59.     salt[2] = '\0';
  60.  
  61.     puts(crypt(argv[1], salt));
  62.  
  63.     return(0);
  64. }
  65.  
  66. ========================================================================
  67.  
  68. -- 
  69. Steve Tate srt@cs.duke.edu | The reason why mathematics enjoys special esteem,
  70. Dept. of Computer Science  | above all other sciences, is that its laws are
  71. Duke University     | absolutely certain and indisputable, while those of all
  72. Durham, NC  27706   | other sciences are to some extent debatable. (Einstein)
  73.