From owner-freebsd-questions Tue Dec 21 7:57:13 1999 Delivered-To: freebsd-questions@freebsd.org Received: from postoffice.onu.edu (postoffice.onu.edu [140.228.10.2]) by hub.freebsd.org (Postfix) with ESMTP id 286A715423 for ; Tue, 21 Dec 1999 07:57:11 -0800 (PST) (envelope-from r-beer@onu.edu) Received: from [140.228.15.35] (asterion.onu.edu [140.228.15.35]) by postoffice.onu.edu (8.9.3/8.9.3) with ESMTP id KAA40372; Tue, 21 Dec 1999 10:55:41 -0500 (EST) (envelope-from r-beer@onu.edu) Message-Id: In-Reply-To: <19991221150917.F728@hades.hell.gr> References: <000601bf4ae3$0ac55780$65010180@lojasobino.com.br> <000601bf4ae3$0ac55780$65010180@lojasobino.com.br> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Tue, 21 Dec 1999 10:55:42 -0500 To: keramida@ceid.upatras.gr, Fabrizzio Batista From: Robert Beer Subject: Re: SALT Algorithm in PERL Cc: freebsd-questions@FreeBSD.ORG Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG At 8:09 AM -0500 12/21/99, Giorgos Keramidas wrote: >On Mon, Dec 20, 1999 at 10:09:17AM -0200, Fabrizzio Batista wrote: >|=20 >| Hi gurus, >|=20 >| I am using a FreeBSD box (3.3 S) in a ISP, and I need to make a >| script that change the users passwords. I am using the PERL language >| to make this, but I don=A5t have the SALT Algorithm. > >If I recall this correctly, you can use a random pair of characters >from the [a-zA-Z0-9./] character class. Given a routine in perl that >returns a random integer between 0..63 (i.e. one called &rand64), you >can use: > > # excuse the too long line here ;) > $universe =3D "./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU= VWXYZ"; > $s0 =3D $universe[&rand64]; > $s1 =3D $universe{&rand64]; > $salt =3D "$s0$s1"; > >or something similar to this one, my perl is not that good, and I might >have made some silly mistake. Here is a snippet of the code I use: @saltset =3D ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '.','/'); # $now =3D time; ($pert1, $pert2) =3D unpack("C2", $username); $week =3D $now / (60*60*24*7) + $pert1 + $pert2; $salt =3D $saltset[$week % 64] . $saltset[$now % 64]; $password =3D crypt($passwd, $salt); --- Bob Beer Ohio Northern University, Academic Computer Services, Ada, OH 45810 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message