|
Posted for a friend, this is his
message;
I need to encript my CGI form URL that is enerated
thru a perl script "page1.cgi". The URL that the CGI script generates is
like:
"name=me&ph=1234" To enscript the above, one suggested me to use character shift to encode the above URL. a->c, b->d, p->r etc.. I tried this. But never thought it is so tough. I could write the 1st function, enc() that changes a->c, n->p, y->a.. but when I try to write dec() that does the reverse, $var = "m"; $var--; does not work.. I cannot find any C like char to int conversion function. please help... thanks.Su $a="pqr"; $b=enc($a); print "$b\n"; //prints "rst" ...ok but sub enc { my $temp=shift; my $ret=''; @temp_array=split(//, $temp); my $len=@temp_array; for (my $i=0; $i<$len; $i++) { if ($temp_array[$i] eq "y") { $temp_array[$i]="a"; } elsif ($temp_array[$i] eq "z") { $temp_array[$i]="b"; } else { $temp_array[$i]++;#works.. $temp_array[$i]++;#works.. #But $temp_array[$i]--; does NOT work!!! } $ret="$ret$temp_array[$i]"; } return($ret); } |
- Re: Character shift to encode string Mark G. Franz
- Re: Character shift to encode string Keith C. Ivey
