영원한사랑

http://www.captcha.ru/en/kcaptcha/
여기 한번 가 보세요. 아마 러시아 개발자들이 아닌가 생각합니다.
이 켑챠는 다른 켑챠와는 달리 코드를 백그라운드와 노이즈 글자 색깔까지 랜덤으로 나오고, 디스토션까지 줄 수 있습니다.  이켑챠의 경우는 뚫릴 확률이 5% 미만으로 나온 아주 훌륭한 켑챠입니다.
제가 생각하는 단점으로는 노이즈와 디스토션이 제일 낮은 값으로 해도 유저층의 연령이 높은 경우 읽기 불편할 때도 있습니다.  그래서 전 코드 내에서 sin, cos 값을 약간 조절하고, 노이즈나 랜덤 칼라 색깔도 조금은 조정하여 씁니다. 그리고 몇가지 더 추가 기능을 더하구요. 그 코드까지는 security code의 성격상 공개할 수는 없구요. 이해해 주세요.

php 초보나 켑챠를 처음 공부하시는 분이라면, 사용하기 쉽고, 이해하기 쉬운 켑챠로는 이런게 있습니다.
http://www.white-hat-web-design.co.uk/articles/php-captcha.php
하지만 위의 켑챠처럼 단순한 경우는 거의 (90%이상) 뚤는 기술이 현재 나와 있습니다. 하지만, 제가 적용하 곳은 아직 뚫리지 않았습니다. 또 스팸어들이 그런 기술까지 도입하면서까지 뚫을려고 하지도 않겠죠. 

켑챠에 대한 연구자료 링크는 저장해 두지 않고, 기억나지 않아서... 패스.

아무튼 여러분 즐 코딩...


나이 좀 있는 개발자, 나야나 입니다.


관련 글...
http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=58089&page=6


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

<?php
session_start();

/*
* File: CaptchaSecurityImages.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 03/08/06
* Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General License for more details:
* http://www.gnu.org/licenses/gpl.html
*
*/

/*
* Modified by 냐야나 on 1/15/2007
*/

class CaptchaSecurityImages {

    var $font = 'monofont.ttf';

    // color must be hex number format.
    // blue on white
    var $background_color = "#FFFFFF" ;
    var $noise_color = "#6478B4" ;
    var $text_color = "#142864" ;
    
    // red on green
    //var $background_color = "#66FF00" ;
    //var $noise_color = "#6478B4" ;
    //var $text_color = "#FF0000" ;
    
    function CaptchaSecurityImages($width='120',$height='40',$characters='6') {
        $code = $this->generateCode($characters);
        /* font size will be 75% of the image height */
        $font_size = $height * 0.75;
        $image = @imagecreate($width, $height) or die('Cannot Initialize new GD image stream');
        
        /* set the colours */
        $rgb_background_color = $this->HEX2RGB( $this->background_color ) ;
        $background_color = imagecolorallocate($image, $rgb_background_color[0], $rgb_background_color[1], $rgb_background_color[2]);
        $rgb_text_color = $this->HEX2RGB( $this->text_color ) ;
        $text_color = imagecolorallocate($image, $rgb_text_color[0], $rgb_text_color[1], $rgb_text_color[2]);
        $rgb_noise_color = $this->HEX2RGB( $this->noise_color ) ;
        $noise_color = imagecolorallocate($image, $rgb_noise_color[0], $rgb_noise_color[1], $rgb_noise_color[2]);
        
        /* generate random dots in background */
        for( $i=0; $i<($width*$height)/3; $i++ ) {
            imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
        }
        
        /* generate random lines in background */
        for( $i=0; $i<($width*$height)/150; $i++ ) {
            imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
        }
        
        /* create textbox and add text */
        $textbox = imagettfbbox($font_size, 0, $this->font, $code);
        $x = ($width - $textbox[4])/2;
        $y = ($height - $textbox[5])/2;
        imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code);
        
        /* output captcha image to browser */
        imagejpeg($image);
        imagedestroy($image);
        $_SESSION['security_code'] = $code;
        
    }
    
    function generateCode($characters) {
        /* list all possible characters, similar looking characters and vowels have been removed */
        $possible = '23456789bcdfghjkmnpqrstvwxyz';
        $code = '';
        $i = 0;
        while ($i < $characters) {
            $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
            $i++;
        }
        return $code;
    }
    
    function HEX2RGB($colorin) {
        $rgb[0] = hexdec(substr($colorin, 1, 2)) ;
        $rgb[1] = hexdec(substr($colorin, 3, 2)) ;
        $rgb[2] = hexdec(substr($colorin, 5, 2)) ;
        return $rgb ;    
    }

}

$width = isset($_GET['width']) ? $_GET['width'] : '120';
$height = isset($_GET['height']) ? $_GET['height'] : '40';
$characters = isset($_GET['characters']) ? $_GET['characters'] : '6';

header('Content-Type: image/jpeg');
$captcha = new CaptchaSecurityImages($width,$height,$characters);

?>

위 코드를 저장한 파일이 CaptchaSecurityImages.php 라면...

폼에서...
<img src="CaptchaSecurityImages.php?characters=6&width=140&height=60">
<input type="text" name="security_code">

받아서...
if ( $_SESSION['security_code'] != $_POST['security_code'] ) {
    에러...
    go back
    exit / return
}

출처:http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=59365&page=1