Location: PHPKode > projects > Atom PhotoBlog > apbMakeCaptcha.php
<?php
   session_name ("apb");
   session_start();
   unset($_SESSION['apbMyCap']);
   $text = rand(1000,10000); //Zufallszahl

   function encrypt($string, $key) {
   $result = '';
   for($i=0; $i<strlen($string); $i++) {
      $char = substr($string, $i, 1);
      $keychar = substr($key, ($i % strlen($key))-1, 1);
      $char = chr(ord($char)+ord($keychar));
      $result.=$char;
   }
   return base64_encode($result);
   }

   $_SESSION['apbMyCap'] = encrypt($text, "jf9wqf82frh"); 
   $_SESSION['apbMyCap'] = str_replace("=", "", $_SESSION['apbMyCap']);

        
   header('Content-type: image/png');
   $img = ImageCreateFromPNG('./apbIcons/captcha/captcha.png'); 
   $color = ImageColorAllocate($img, 0, 0, 0); 
   $ttf = "./apbIcons/captcha/arial.ttf"; 
   $ttfsize = 25; 
   $angle = rand(0,5);
   $t_x = rand(5,50);
   $t_y = 35;
   imagettftext($img, $ttfsize, $angle, $t_x, $t_y, $color, $ttf, $text);
   imagepng($img);
   imagedestroy($img);
?> 
Return current item: Atom PhotoBlog