common.pl
上传用户:dostar
上传日期:2007-01-04
资源大小:21k
文件大小:1k
源码类别:

WEB邮件程序

开发平台:

Perl

  1. #!/usr/local/bin/perl
  2. ##########
  3. #
  4. # Common functions used by some scripts
  5. #
  6. #
  7. ##########
  8. sub cryptit {
  9. my ($string)=@_;
  10. my $crypted="";
  11. my $i;
  12. for ($i=0;$i<length($string);$i++) {
  13. my $tmpcrypt=ord(substr($string,$i,1))+ord(substr($keycrypt,(abs(cos($i))*3),1));
  14. my $crypt1=chr(int($tmpcrypt/2));
  15. my $crypt2=chr($tmpcrypt-int($tmpcrypt/2));
  16. $crypted.=$crypt1.$crypt2;
  17. }
  18. return $crypted;
  19. }
  20. sub decryptit {
  21.     my ($string)=@_;
  22.     my $decrypted="";
  23.     my $i;
  24.     for ($i=0;$i<length($string);$i=$i+2) {
  25.         my $decrypt1=substr($string,$i,1);
  26. my $decrypt2=substr($string,$i+1,1);
  27. my $tmpdecrypt=ord($decrypt1)+ord($decrypt2); 
  28. $decrypted.=chr($tmpdecrypt-ord(substr($keycrypt,(abs(cos(int($i/2)))*3),1)));
  29.     }
  30. return $decrypted;
  31. }
  32. $SIG{__DIE__} = &mydie;
  33. sub mydie {
  34. print "Content-type: text/htmlnn<b>@_</b>";
  35. exit 1;
  36. }
  37. return 1;