From owner-freebsd-stable Tue Jul 10 20: 8:52 2001 Delivered-To: freebsd-stable@freebsd.org Received: from aurora.corp.flipdog.com (c1082929-a.saltlk1.ut.home.com [65.11.115.83]) by hub.freebsd.org (Postfix) with ESMTP id E5BEA37B408 for ; Tue, 10 Jul 2001 20:08:46 -0700 (PDT) (envelope-from jlp@flipdog.com) Received: from aurora (localhost [127.0.0.1]) by aurora.corp.flipdog.com (Postfix) with ESMTP id 67ED041E6E; Tue, 10 Jul 2001 09:05:32 -0600 (MDT) X-Mailer: exmh version 2.3.1 01/19/2001 with nmh-1.0.4 To: Walter Campbell From: "Jan L. Peterson" Cc: Mike Tancsa , Jim Weeks , stable@FreeBSD.ORG Subject: Re: Generating encrypted passwords X-face: p=61=y<.Il$z+k*y~"j>%c[8R~8{j3WTnaSd-'RyC>t.Ub>AAm\zYA#5JF +W=G?EI+|EI);]=fs_MOfKN0n9`OlmB[1^0;L^64K5][nOb&gv/n}p@mm06|J|WNa asp7mMEw0w)e_6T~7v-\]yHKvI^1}[2k)] References: In-reply-to: Your message of "Tue, 10 Jul 2001 10:24:55 EDT." Mime-Version: 1.0 Content-Type: multipart/mixed ; boundary="==_Exmh_740581280" Date: Tue, 10 Jul 2001 09:05:32 -0600 Message-Id: <20010710150532.67ED041E6E@aurora.corp.flipdog.com> Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG This is a multipart MIME message. --==_Exmh_740581280 Content-Type: text/plain; charset=us-ascii wcampbel@botbay.net said: > A DES (and MD5) salt (and the rest of the hash) can contain a-z A-Z > 0-9 . and / Exactly... since we seem to be sharing, here's my script. No comments, please, about how it's not a very good password. It's good enough for my purposes (generating an initial password for a user account or htaccess file, typically). I know that crack would eat these passwords for breakfast. I use a different algorithm for generating passwords that are "important"... the FIPS 181 standard. -jan- -- Jan L. Peterson --==_Exmh_740581280 Content-Type: text/plain ; name="mkpw"; charset=us-ascii Content-Description: mkpw Content-Disposition: attachment; filename="mkpw" #! /usr/local/bin/perl # # mkpw: generate a random password *or* display the crypted password # for a given plain text password (and optionally, salt) # # - Jan L. Peterson @saltchars = ('.', '/', '0'..'9', 'A'..'Z', 'a'..'z'); $clear = shift; $salt = shift; $salt = &makesalt unless defined($salt); $clear = &makepw unless defined($clear); $pass = crypt($clear, $salt); print "$clear -> $pass\n"; sub makesalt { return($saltchars[int(rand(scalar(@saltchars)))] . $saltchars[int(rand(scalar(@saltchars)))]); } sub makepw { open(WORDS, '/usr/share/dict/words'); while () { chop; $len = length($_); push(@three, $_) if $len == 3; push(@four, $_) if $len == 4; } close(WORDS); @sep = ('0'..'9', split(m//, '+,/=?^%*')); if (rand(2) >= 1) { $word = $three[int(rand(scalar(@three)))] . $sep[int(rand(scalar(@sep)))] . $four[int(rand(scalar(@four)))]; } else { $word = $four[int(rand(scalar(@four)))] . $sep[int(rand(scalar(@sep)))] . $three[int(rand(scalar(@three)))]; } return($word); } --==_Exmh_740581280-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message