2010-09-11 181 views
0

我創建了一個驗證碼圖像製作程序與PHP驗證碼加密

<?php 
function word($n) { 
    $consonants = "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ"; 
    $vowels = "aeiou"; 
    $word[1] = $consonants[rand(0, 41)]; 
    $word[2] .= $vowels[rand(0, 4)]; 
    $word[3] .= $consonants[rand(0, 41)]; 
    $word[4] .= $consonants[rand(0, 41)]; 
    return $word[$n]; 
} 

    $xs = 550; 
    $ys = 300; 
    $im = imagecreatetruecolor($xs, $ys); 
    $newim = imagecreatetruecolor($xs, $ys); 
    imagettftext($im, $ys/5, rand(-10, 10), rand(0, 10), $ys/2, 0xFFFFFF, "geosans.ttf", word(1)); 
    imagettftext($im, $ys/4.5, rand(-10, 10), rand(50, 70), $ys/2, 0xFFFFFF, "geosans.ttf", word(2)); 
    imagettftext($im, $ys/4, rand(-10, 10), rand(100, 150), $ys/2, 0xFFFFFF, "geosans.ttf", word(3)); 
    imagettftext($im, $ys/3.5, rand(-10, 10), rand(185, 210), $ys/2, 0xFFFFFF, "geosans.ttf", word(4)); 
    for ($x=0; $x<=$xs;$x++){ 
     for ($y=0; $y<=$ys;$y++){ 
      $rgba = imagecolorsforindex($im, imagecolorat($im, $x, $y)); 
      $col = imagecolorallocate($newim, $rgba["red"], $rgba["green"], $rgba["blue"]); 

      $distorted_y = ($y + round(45*sin($x/50)) + imagesy($im)) % imagesy($im); 
      imagesetpixel($newim, $x, $distorted_y, $col); 
     } 
    } 

    imagefilter($newim, IMG_FILTER_NEGATE); 


    header("Content-type: image/png"); 
    imagepng($newim); 
?> 

但我怎麼能申請嗎?

怎樣的官方驗證碼網站加密他們的真實

這是一個例子

http://www.google.com/recaptcha/api/image?c=03AHJ_VutAc1sMxyCE0N98Kh2AfMGlGmu7_DzzFP3Rn1gLHdbDulOQYK0w-sVrxqHWSTBCfVBipmqY-ywmme2_cuClW5QBRzKdzRSJeMWyme1aoGZ-y0OluiSfn-uKDExfVCo2PGrTao2wWpBLultbUEsctlJ97JXKCQ

總的來說,我問我怎麼能放心地加密數據?

回答

2

谷歌擁有數以百萬計的用戶,而且我確信每天都會被惡意機器人定位數十萬次。在某些情況下,像base64_encode可以工作 - 在谷歌的情況下,他們可能使用PGP(這對大多數應用程序來說是過度的)。在我看來,中間立場是沿着base64編碼MCRYPT的行(保持查詢字符串URL友好)。

http://us2.php.net/mcrypt

http://us2.php.net/base64_encode