Hi David
You can create a random key to encrypt a password:
my $key = join '', ('.','/',0..9,'A'..'Z','a'..'z')[rand
64, rand 64];
(Took this from the book "Beginning Perl" by Simon Cozens)
Then you encrypt the password:
$clave = crypt($cgi->param('password'),$key);
Now you can store $clave as your encrypted password.
Then you can check the password back:
(Lets suppose $password is the parameter entered by the user and
usuariosis[6] is the stored value)
*if (crypt($password, $usuariosis[6]) ne $usuariosis[6]) #check
input vs. stored
{
#Bad Password
}
else
{
#Good Password
** }*
I hope this helps.
Pablo
> From: David vd Geer Inhuur tbv IPlib <[EMAIL PROTECTED]>
>
> Message-Id: <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: How to use crypt ??
> Mime-Version: 1.0
> Content-Type: text/plain;
> charset=us-ascii
> Content-Transfer-Encoding: 7bit
> Content-MD5: ircFB0BQNAE374VOrbLqzw==
> Status: R
> X-Status: N
>
>
> Hi,
>
> Right now I am a little lost myself.
>
> Trying to use crypt() to encrypt a given password.
> I know how to compare a given password with an encrypted one, but to encrypt one
> myself and save it, doesn't work for me for some reason.
> You would say, Ah of course forgotten to give your encryption key. That's right
> which one uses apache/Unix/etc ??
>
> So what it is all about probably is this :
>
> my $crpw = crypt("$pw", "What key ????");
>
> Hope for your help !
>
> Regs David
>
>
> For giving you the overview, here is my program :
>
> #!/usr/bin/perl
>
> use CGI qw(:standard);
> use strict;
>
> print header,
> start_html(-Title =>"Create external user", -BGCOLOR=>"#99cccc"),
> h1('Create external user'),
> start_form, table,
> Tr(td("Please enter userid"), td(textfield('userid') )),p,
> Tr(td("Please enter password"), td(password_field('pw') )),p,
> Tr(td("Please select group"), td(popup_menu('group', [ qw(iclab Philips All)
>]) )),p,
> Tr(td(submit(-Value =>"Create")));
> print "</table>";
> print end_form;
>
>
> if (param('pw')) {
>
> my $pw = param('pw');
> my $userid = param('userid');
> my $group = param('group');
>
> my $crpw = crypt($pw);
> my $pwline = "${userid}:${crpw}";
>
> print $pwline;
>
> }
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]