Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Dec 1999 10:55:42 -0500
From:      Robert Beer <r-beer@onu.edu>
To:        keramida@ceid.upatras.gr, Fabrizzio Batista <fabrizzio.batista@lojasobino.com.br>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: SALT Algorithm in PERL
Message-ID:  <l03130325b485531f53ea@[140.228.15.35]>
In-Reply-To: <19991221150917.F728@hades.hell.gr>
References:  <000601bf4ae3$0ac55780$65010180@lojasobino.com.br> <000601bf4ae3$0ac55780$65010180@lojasobino.com.br>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <r-beer@onu.edu>
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?l03130325b485531f53ea>