验证码加密 [英] Captcha encryption
本文介绍了验证码加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用PHP创建了一个验证码图像制作程序
I have created a captcha image making program with 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);
?>
但是如何应用?
官方验证码网站如何加密他们的
这是一个例子
总之,我问如何安全地加密我的数据?
推荐答案
你可以按照你可以存储的方式数据库中的密码。使用一些随机的SALT将其与MD5一起使用。
you could do it the same way as you could store passwords in your database. Hash them with MD5 with some random sort of SALT.
http://www.pixel2life.com/publish/tutorials/118/understanding_md5_password_encryption/
这篇关于验证码加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文