【问题标题】:Captcha encryption验证码加密
【发布时间】:2011-04-11 05:09:10
【问题描述】:

我用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

总的来说,我在问如何安全地加密我的数据?

【问题讨论】:

    标签: php encryption gd captcha recaptcha


    【解决方案1】:

    您可以像在数据库中存储密码一样执行此操作。用 MD5 和某种随机的 SALT 对它们进行散列。

    http://www.pixel2life.com/publish/tutorials/118/understanding_md5_password_encryption/

    【讨论】:

      【解决方案2】:

      Google 拥有数百万用户,我敢肯定,恶意机器人每天都会以数十万次为目标。在某些情况下,base64_encode 之类的东西会起作用——在谷歌的情况下,他们可能使用 PGP(这对大多数应用程序来说太过分了)。在我看来,中间立场是类似于 base64 编码的 MCRYPT(以保持查询字符串 URL 友好)。

      http://us2.php.net/mcrypt

      http://us2.php.net/base64_encode

      【讨论】:

        猜你喜欢
        • 2013-03-21
        • 1970-01-01
        • 1970-01-01
        • 2014-08-09
        • 2011-08-29
        • 2014-08-12
        • 2011-01-24
        • 1970-01-01
        相关资源
        最近更新 更多