while submitting an html, it will call a cgi written in encrypted form. I am decrypting that code and stored in $p variable (written in test2.pl). But i am not able to get the result in browser. How can i solve this problem.
html code --------- <HTML> <HEAD> <TITLE> Test </TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> <form name="test" action="/cg-bin/test2.pl" method= "post"> Name : <input type="text" name="name"><br> Age : <input type="text" name="age"><br> <input type="submit" name="submit" value="submit"> </form> </BODY> </HTML> ------------------------ and cgi code: test2.pl --------------------- #!/usr/bin/perl print "Content-type: text/html\n\n"; $p="snhnhaayshasaaahsasfanfdzahdayazazaaadanssaysiaaskzdhxshszsfscaxam +fhzahdayazazaaadanhmsdamsfhxhnaaashzaksfhchahhasshzdhxaxafsfscapayhxh +kaoavhahvhohszzsssdamsfhzhnhozfskakscaiapzmzkayaosxspashzzdzyhvsysoaf +hizkdzfsfszdansmazzdzkhnavsxscansxhczfhxsffyavfvamskaxachoakakaaazhnz +yasaxaiszhyakazaaazavaxdfhchsszadsyasssznfkfadfhzsfshap"; my $encryptkey = "drbidsearch"; $p = &Decrypt($p,$encryptkey,'asdfhzxcvnmpoiyk'); sub Decrypt { my ($encrypted, $key, $pub_key) = @_; $encrypted =~ s/[\n\r\t\f]//eg; my ($cr,$index,$decode,$decode2,$char,$key_char,$dec_string,$decry +pted) = ''; while ( length($key) < length($encrypted) ) { $key .= $key } $key=substr($key,0,length($encrypted)); while ($index < length($encrypted)) { $decode = sprintf("%1x", index($pub_key, substr($encrypted,$in +dex,1))); $index++; $decode2 = sprintf("%1x", index($pub_key, substr($encrypted,$i +ndex,1))); $index++; $dec_string .= chr(hex("$decode$decode2")); } $index=0; while( $index < length($dec_string) ) { $char = substr($dec_string,$index,1); $key_char = substr($key,$index,1); $decrypted .= chr(ord($char) ^ ord($key_char)); $index++; } $cr = '·¨ '; $decrypted =~ s/$cr/\r/g; return &rot13( $decrypted ); } sub rot13{ my $source = shift (@_); $source =~ tr /[a-m][n-z]/[n-z][a-m]/; $source =~ tr /[A-M][N-Z]/[N-Z][A-M]/; $source = reverse($source); return $source; } ---------
Note: - $p stores values as .. use CGI;
print "Content-type: text/html\n\n"; $query = new CGI; $nam = $query->param ( 'name' ); $na="test"; if ($na eq $nam) { print "Correct"; } else { print "Incorrect"; }
If i save this as test2.pl and run , it will print result.

update (broquaint): added <code> tags


In reply to decrypt can not be able to print result by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.