codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Security - Code verify  gsr at 21:52 on Thursday, October 18, 2007
 

Hi there,

I am Gerard, 1st year student of Perl at the university.
I came across some lines of code from a script done by an ex student that left uni and did not left any explanation of the code.

The only thing I know is that the script reads an external file that contains 2 lines of code.
The 1st and 2nd lines on this file are:


BEGIN!! Addr:* Name:John
-
4DZWJMZMX44ZiaZ4 END!!

I think it compares both lines on the script and return true if equal.

Could some one please explain me better, and how can I create the second line? is it in HExadecimal or what?

Below is the code on the script:



$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;
};




Thanks for all your help
Gerard


  Re: Security - Code verify  mimir at 00:37 on Saturday, October 20, 2007
 

Whoever made this code should be a teacher in how NOT to write code.










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Chat application
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..
•  Re: Security - Code verify
•  Job @ EarlySail


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007