Re: Making Linux User Password using perl
by Vikasumit other posts by this author
Jun 22 2006 3:34AM messages near this date
view in the new Beta List Site
Re: Making Linux User Password using perl
|
Re: Making Linux User Password using perl
FRAMEWORK Hi,
Code i send previously is quite similar to yours its that you generate salt
from password or from time stamp,
But when I try this code in windows machine i got password as string with
out salt embeded in it
where as in linux password saved as $1$somesalt$<password>
but it runs perfectly underlinux ...why is it so
Thanks
Sumit Gupta
On 6/22/06, $Bill Luebkert <dbecoll@[...].net> wrote:
>
> Vikasumit wrote:
>
> > Hi,
> >
> > I am writing a Perl Script that a user run to make linux user password
> > style password ....
> >
> > I mean If a user type "password"
> >
> > I can save this password such that I just replace it in /etc/shadow
> > password coulmn and his password changes.
> >
> > I can generate password using PHP crypt function but not through perl
> > please help...
>
> This belongs in win32-users group.
>
> Untested in this form:
>
> use strict;
> use warnings;
>
> my $chk_only = 0;
> my $plainpasswd = shift; # get commandline arg for password
> my $crypted_passwd = crypt_passwd ($plainpasswd);
> print "encrypted passwd = '$crypted_passwd'\n";
> exit;
>
> sub crypt_passwd { # $crypted_passwd = crypt_passwd ($plainpasswd [,
> $salt]);
> my $passwd = shift;
> my $salt;
>
> # if salt supplied
>
> if (defined $_[0]) {
>
> $salt = substr $_[0], 0, 2; # get first 2 chars for salt
>
> # else create a salt using time, pid and rand
>
> } else {
>
> if ($chk_only) {
> $salt = substr $enc_passwd, 0, 2; # get first 2 for
> salt
> } else {
> my $tmp = (time + $$) % 65536;
> srand ($tmp);
> $salt = $legal_enc[sprintf "%u", rand (@legal_enc)];
> $salt .= $legal_enc[sprintf "%u", rand (@legal_enc)];
> }
> }
>
> my $new_passwd = crypt ($passwd, $salt);
> return $new_passwd;
>
> }
>
Thread:
Vikasumit
$Bill Luebkert
Vikasumit
$Bill Luebkert
Vikasumit
|