common.pl
上传用户:dostar
上传日期:2007-01-04
资源大小:21k
文件大小:1k
- #!/usr/local/bin/perl
- ##########
- #
- # Common functions used by some scripts
- #
- #
- ##########
- sub cryptit {
- my ($string)=@_;
- my $crypted="";
- my $i;
- for ($i=0;$i<length($string);$i++) {
- my $tmpcrypt=ord(substr($string,$i,1))+ord(substr($keycrypt,(abs(cos($i))*3),1));
- my $crypt1=chr(int($tmpcrypt/2));
- my $crypt2=chr($tmpcrypt-int($tmpcrypt/2));
- $crypted.=$crypt1.$crypt2;
- }
- return $crypted;
- }
- sub decryptit {
- my ($string)=@_;
- my $decrypted="";
- my $i;
- for ($i=0;$i<length($string);$i=$i+2) {
- my $decrypt1=substr($string,$i,1);
- my $decrypt2=substr($string,$i+1,1);
- my $tmpdecrypt=ord($decrypt1)+ord($decrypt2);
- $decrypted.=chr($tmpdecrypt-ord(substr($keycrypt,(abs(cos(int($i/2)))*3),1)));
- }
- return $decrypted;
- }
- $SIG{__DIE__} = &mydie;
- sub mydie {
- print "Content-type: text/htmlnn<b>@_</b>";
- exit 1;
- }
- return 1;