Home: General Discussions: Internet Security:
Compare strings

New User

Oct 17, 2007, 3:37 PM

Views: 435148
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?


New User

Oct 18, 2007, 9:20 AM

Views: 435143
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;
$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.



New User

Oct 18, 2007, 9:23 AM

Views: 435142
Re: [gsr] Compare strings

Please, bear in mind I am new to Perl.

Thank for your help in advance.


Oct 18, 2007, 12:51 PM

Views: 435141
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.

New User

Sep 19, 2010, 11:11 PM

Views: 427018
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