CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: General Discussions: Internet Security:
Compare strings


New User

Oct 17, 2007, 3:37 PM

Post #1 of 5 (435398 views)
Compare strings Can't Post

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

Post #2 of 5 (435393 views)
Re: [gsr] Compare strings [In reply to] Can't Post

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

Post #3 of 5 (435392 views)
Re: [gsr] Compare strings [In reply to] Can't Post

Please, bear in mind I am new to Perl.

Thank for your help in advance.


Oct 18, 2007, 12:51 PM

Post #4 of 5 (435391 views)
Re: [gsr] Compare strings [In reply to] Can't Post

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 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

Post #5 of 5 (427268 views)
Re: [gsr] Compare strings [In reply to] Can't Post

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=]seo pecialist


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives