Home: General Discussions: Internet Security:
Compare strings



gsr
New User

Oct 17, 2007, 3:37 PM


Views: 391466
Compare strings

I have to create some sort of security for my script. If I use as administrator than it enters a different HTML for admin, but if my free users enter their code than the system will let a different type of HTMl to be read by the users.

The code must be into the pearl script.


Any ideas?

G


gsr
New User

Oct 18, 2007, 9:20 AM


Views: 391461
Re: [gsr] Compare strings

Well, some one send me the code below and said that it reads a text file with 2 arrays, the 1st array has a normal character and the second has a HEX chrs, and return false if both aare different.


Here is the code



$const{'code_validate'} = sub {
my $p_decode = sub {
local $_;
my $code = defined($_[0]) ? $_[0] : '';
my %map = ();
my $i = 0;
foreach (48..57,65..90,97..122) {
$map{chr($_)} = $i % 16;
$i++;
}
$code =~ s!\s|\r|\n|\015|\012!!sg;
my $text = '';
my $frag = '';
$i = 0;
while ($frag = substr($code, $i, 2)) {
$i += 2;
my $chn = 16 * $map{substr($frag,0,1)};
$chn += $map{substr($frag,1,1)};
my $ch = chr($chn);
$text .= $ch;
}
$text = unpack('u',$text);
return $text;
};
local $_;
my $code = defined($_[0]) ? $_[0] : '';
return 0 unless ($code);
my $is_valid = 0;
$code =~ s!BEGIN!!sg;
$code =~ s!END!!sg;
if ($code =~ m!^\s*(.*)\s*\-\s*(.*?)\s*$!s) {
my ($pub, $pri) = ($1,$2);
$pri = &$p_decode($pri);
$pub =~ s!(\s|\r|\n)!!sg;
$pri =~ s!(\s|\r|\n)!!sg;
if ($pub eq $pri) {

$is_valid = 1;
}
}
return $is_valid;
};





Could some of you guys explained to me?

I cannot understand much, but this person also is new at Perl.

Regards,

Gerard


gsr
New User

Oct 18, 2007, 9:23 AM


Views: 391460
Re: [gsr] Compare strings

Please, bear in mind I am new to Perl.

Thank for your help in advance.
Gerard


KevinR
Veteran


Oct 18, 2007, 12:51 PM


Views: 391459
Re: [gsr] Compare strings

That code appers to have nothing to do with your original question, which you have posted in the wrong forum anyway. Your question is not about internet security, but how to add authentication (login credentials) for a seperate admin area. There is no one size fits all answer. I suggest since you are very inexperienced with perl that you find a canned script on a script archive site (like www.hotscripts.com) and see if you can use one of them for your needs. Look for "members" type scripts.
-------------------------------------------------


chrisadam2
New User

Sep 19, 2010, 11:11 PM


Views: 383336
Re: [gsr] Compare strings

In this tutorial I'll demonstrate several different ways to correctly compare Java strings, starting with the approach I use most of the time. At the end of this Java String comparison tutorial I'll also discuss why the "==" operator doesn't work when comparing Java strings.

__________________________________________

Want to get-on Google's first page and loads of traffic to your website? Hire a SEO Specialist from Ocean Groups [url= http://oceangroups.org/]seo pecialist