From gresser@informatik.uni-muenchen.de Thu Aug 10 14:28:01 1995 Message-Id: <199508101226.AA16630@zeus.cip.informatik.uni-muenchen.de> From: Christian Gresser Subject: Re: Password generator To: ulla@Stupi.SE Date: Thu, 10 Aug 1995 14:26:16 +0200 (MESZ) In-Reply-To: from "Ulla Sandberg" at Aug 9, 95 12:45:55 pm X-Mailer: ELM [version 2.4 PL23] Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Content-Length: 2614 Hi, > I`m looking for a password generator, something to generate new > passwords for a lot of accounts. I use this one. It can be included in every perl-program, we use one here for our user-management. --- cut here --- #!/bin/perl # # makes a random password for all new accounts # sub make_password { local( $idx, $pw, $str ) = ( 1, "", "" ); local( $valid ) = "abcdefghijklmnopqrstuvwxyz" . "ABCDEFGHIJKLMNOPQRSTUVWXYZ" . "1234567890"; local( $vlen ) = ( $valid ); # first character must be a letter # $str = substr( $valid, int(rand(52)), 1 ); while ( $idx++ < 8 ) { $pw = $pw . $str; $str = substr( $valid, int(rand(length($valid))), 1 ); } $pw; } --- cut here --- A Friend of mine uses this one --- cut here --- #! /usr/local/dist/bin/perl srand; foreach $passwd (@ARGV) { # generate salt # $salt = rand(65535); $saltc[0] = $salt & 077; $saltc[1] = ($salt >> 6) & 077; for ($i = 0; $i < 2; $i++) { $c = $saltc[$i] + ord('.'); $c += 7 if ($c > ord('9')); $c += 6 if ($c > ord('Z')); $saltc[$i] = $c; } print(crypt($passwd, $salt), "\n"); } --- cut here --- and I found another on --- cut here --- /* * htpasswd.c: simple program for manipulating password file * * Rob McCool * * Changes by A.Jung, 1994-07-12 */ #include #include #include #include char *crypt (char *pw, char *salt); char *strd (char *s) { char *d; d = (char *) malloc (strlen (s) + 1); strcpy (d, s); return (d); } static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; void to64 (s, v, n) register char *s; register long v; register int n; { while (--n >= 0) { *s++ = itoa64[v & 0x3f]; v >>= 6; } } void main () { char *pw, *cpw, salt[3]; pw = strd (getpass ("Please enter password:")); if (strlen (pw) < 6) { fprintf (stderr, "The password has to be at least 6 characters long\n"); exit (1); } if (strcmp (pw, getpass ("Re-type this password:"))) { fprintf (stderr, "They don't match, sorry.\n"); exit (1); } (void) srand ((int) time ((time_t *) NULL)); to64 (&salt[0], rand (), 2); cpw = crypt (pw, salt); free (pw); printf ("the passwort ist: %s\n", cpw); } --- cut here --- choose one ;-) Bye. Chris. gresser@informatik.uni-muenchen.de