home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / oberon-a-1.4ß.lha / Oberon-A / source / Misc / GenPasswd.mod next >
Text File  |  1994-08-08  |  2KB  |  92 lines

  1. (*
  2.      $RCSfile: GenPasswd.mod $
  3.   Description: Unix password generator.
  4.  
  5.    Created by: fjc (Frank Copeland)
  6.     $Revision: 1.2 $
  7.       $Author: fjc $
  8.         $Date: 1994/06/05 22:24:19 $
  9.  
  10.   Copyright © 1994, Frank Copeland.
  11.   This file is part of Oberon-A.
  12.   See Oberon-A.doc for conditions of use and distribution.
  13.  
  14.   Log entries are at the end of the file.
  15.  
  16.   I wrote this program after I apparently had my university account broken
  17.   into.  It simply generates a random string of characters of a given
  18.   length.
  19. *)
  20.  
  21. MODULE GenPasswd;
  22.  
  23. (*$P-*)
  24.  
  25. IMPORT Errors, Args, RN := RandomNumbers, IO := StdIO;
  26.  
  27. CONST
  28.   VersionTag = "\0$VER: GenPasswd 1.1 (5.6.94)";
  29.   VersionStr = "GenPasswd 1.1 (5 Jun 1994)\r\n";
  30.   CopyrightStr = "Copyright © 1993-1994 Frank Copeland\n\n";
  31.  
  32. CONST
  33.   startChar = ORD ("!");
  34.   range = ORD ("~") - ORD ("!") + 1;
  35.  
  36. VAR i, j, numChars, count : LONGINT;
  37.  
  38. (*------------------------------------*)
  39. (*$D-*)
  40. PROCEDURE StrToInt (s : ARRAY OF CHAR) : LONGINT;
  41.  
  42.   VAR i, j : LONGINT;
  43.  
  44. BEGIN (* StrToInt *)
  45.   i := 0; j := 0;
  46.   WHILE s [i] # 0X DO
  47.     IF (s[i] < "0") OR (s[i] > "9") THEN
  48.       IO.WriteStr (" !! Error: Illegal char in parameter\n");
  49.       HALT (20)
  50.     END;
  51.     j := (j * 10) + (ORD (s[i]) - ORD ("0"));
  52.     INC (i)
  53.   END;
  54.   RETURN j
  55. END StrToInt;
  56.  
  57. BEGIN
  58.   IO.WriteStr (VersionStr);
  59.   IO.WriteStr (CopyrightStr);
  60.   IF Args.argc = 1 THEN
  61.     count := 1; numChars := 8
  62.   ELSIF Args.argc = 2 THEN
  63.     count := 1; numChars := StrToInt (Args.argv [1]^)
  64.   ELSIF Args.argc = 3 THEN
  65.     numChars := StrToInt (Args.argv [1]^);
  66.     count := StrToInt (Args.argv [2]^)
  67.   ELSE
  68.     IO.WriteStr ("Usage: GenPasswd [<password length>] [<# of passwords>]");
  69.     HALT (10)
  70.   END;
  71.   RN.TimeSeed;
  72.   FOR i := 1 TO count DO
  73.     FOR j := 1 TO numChars DO
  74.       IO.Write (CHR (ENTIER (RN.Uniform () * range) + startChar))
  75.     END;
  76.     IO.WriteLn()
  77.   END
  78. END GenPasswd.
  79.  
  80. (***************************************************************************
  81.  
  82.   $Log: GenPasswd.mod $
  83.   Revision 1.2  1994/06/05  22:24:19  fjc
  84.   - Added count parameter
  85.  
  86.   Revision 1.1  1994/05/12  20:20:07  fjc
  87.   - Prepared for release
  88.  
  89.  
  90. ***************************************************************************)
  91.  
  92.