M
madan
hi all,
i have a problem when using the function "crypt" in my code...
i want to encrypt a password when a user enters his password in the
textfield..
i wrote a simple code which will be called by itself and accept the
password..encrypt it and displays the ecrypted one and again asks for
another password..
Problem is that it is showing the same result for what ever text i
enter..i am using perl 5.6..
this code is working when tried in console(without CGI)...but when used
CGI i get the error...
the code is as below...
***********************************************************************************
#! c:\perl\bin\perl
use strict;
use CGI;
use CGI::Carp 'fatalsToBrowser';
my($cgi,$element,%passlist,$encrypted_password,$password);
$cgi=CGI->new;
print $cgi->header;
print $cgi->start_html;
foreach $element ($cgi->param)
{
$passlist{$element} = $cgi->param($element);
}
print "<form action=\"/cgi-bin/sample/encrypt.pl\">";
if($passlist{'gave'})
{
($encrypted_password) = &encrypt_text($password);
print "<br>the password you entered has been encrypted to
:$encrypted_password";
}
print "<br>Enter your password";
print "<br><input type=text name=\"pword\">";
print "<br><input type=submit value=\"Submit\">";
print "<input type=hidden name=\"gave\" value=\"true\">";
sub encrypt_text
{
my($text)=(@_);
my ($test,$encrypted_text);
$test = length($text).$text;
$text = length($text).$text;
$encrypted_text = crypt($text,$test);
return $encrypted_text;
}
****************************************************************************
thanks in advance
with regards
madan
i have a problem when using the function "crypt" in my code...
i want to encrypt a password when a user enters his password in the
textfield..
i wrote a simple code which will be called by itself and accept the
password..encrypt it and displays the ecrypted one and again asks for
another password..
Problem is that it is showing the same result for what ever text i
enter..i am using perl 5.6..
this code is working when tried in console(without CGI)...but when used
CGI i get the error...
the code is as below...
***********************************************************************************
#! c:\perl\bin\perl
use strict;
use CGI;
use CGI::Carp 'fatalsToBrowser';
my($cgi,$element,%passlist,$encrypted_password,$password);
$cgi=CGI->new;
print $cgi->header;
print $cgi->start_html;
foreach $element ($cgi->param)
{
$passlist{$element} = $cgi->param($element);
}
print "<form action=\"/cgi-bin/sample/encrypt.pl\">";
if($passlist{'gave'})
{
($encrypted_password) = &encrypt_text($password);
print "<br>the password you entered has been encrypted to
:$encrypted_password";
}
print "<br>Enter your password";
print "<br><input type=text name=\"pword\">";
print "<br><input type=submit value=\"Submit\">";
print "<input type=hidden name=\"gave\" value=\"true\">";
sub encrypt_text
{
my($text)=(@_);
my ($test,$encrypted_text);
$test = length($text).$text;
$text = length($text).$text;
$encrypted_text = crypt($text,$test);
return $encrypted_text;
}
****************************************************************************
thanks in advance
with regards
madan