home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 13209 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  1.9 KB

  1. Path: sparky!uunet!wupost!waikato.ac.nz!aukuni.ac.nz!cs18.cs.aukuni.ac.nz!pgut1
  2. Newsgroups: comp.lang.c
  3. Subject: Re: Password encryption?
  4. Message-ID: <1992Sep4.073201.28500@cs.aukuni.ac.nz>
  5. From: pgut1@cs.aukuni.ac.nz (Peter Gutmann)
  6. Date: Fri, 4 Sep 1992 07:32:01 GMT
  7. Sender: pgut1@cs.aukuni.ac.nz (PeterClaus          Gutmann        )
  8. References: <julian.715516516@sun-1> <18574tINNoh@darkstar.UCSC.EDU>
  9. Organization: Computer Science Dept. University of Auckland
  10. Keywords: password, encryption
  11. Lines: 36
  12.  
  13. In <18574tINNoh@darkstar.UCSC.EDU> noesis@ucscb.UCSC.EDU (95016000) writes:
  14.  
  15. >In article <julian.715516516@sun-1> julian@sun-1.cs.uct.ac.za (Julian Hansen) writes:
  16. >>Hi world,
  17. >>
  18. >>I need to do some password encryption and maybe data encryption to. Anyone
  19. >>out there like to help me. Some code would be nice and maybe a few pointers
  20. >>on what not to do (and what to do). Any help would be most appreciated.
  21. >>
  22. >here's what i use with some success:
  23.  
  24. >long encrypt(char *s)
  25. >{
  26. >  long result=1;
  27. >  char *ptr;
  28.  
  29. >  srand(0x1234);
  30. >  for (ptr=s; *ptr; ptr++)
  31. >    result+=(*ptr)*rand();
  32. >  return result;
  33. >}
  34.  
  35. Don't rely on this for security.  What you're doing is xor-ing your data
  36. stream with a LCRNG (linear congruential random number generator).  These are
  37. quite easy to break, for example the paper "How to Predict Congruential
  38. Generators" presented at Crypto '89 gives much information on this (plus a lot
  39. of references to other papers).  This approach is enough to keep the plebs
  40. out, but won't withstand any real attack.  If you want to perform password
  41. encryption you really should use a one-way hash function such as MD5, Snefru,
  42. or the NIST SHA (by an amazing coincidence :-) I posted SHA source code to
  43. sci.crypt about 15 minutes ago, you could grab that and use it).
  44.  
  45. Peter.
  46. --
  47.      pgut1@cs.aukuni.ac.nz || peterg@kcbbs.gen.nz || peter@nacjack.gen.nz
  48.           (Email is currently not terribly reliable)
  49.