Re: HN CAPTCHA at http://www.phpclasses.org

From: Date: Thu, 16 Feb 2006 06:41:05 +0000
Subject: Re: HN CAPTCHA at http://www.phpclasses.org
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-230517@lists.php.net to get a copy of this message
On 2/16/06, Roger Thomas <sniper@home.net.my> wrote: > I am currently testing HN CAPTCHA and noticed that the range of alphabets that were produced > ranges from A..F only. My PHP skill is quite limited to change that to A..Z so if ppl here have any > experience with that class, appreciate your thoughts. TIA. The reason this CAPTCHA class only returns letters between A-F is because it uses the md5() function in php to get a (more or less) random string. MD5 hashes contains of a 32-character hexadecimal numbers, which in turn ranges from 0 to F. To solve your problem, replace the generate_private() function in hn_captcha.class.php - starting at row 756 - with this code: function generate_private($public="") { $letters = "1234567890abcdefghijklmnopqrstuvwxyz"; $maxsize = strlen($letters)-1; for($i=0;$i<6;$i++){ $rstring .= $letters{mt_rand(0, $maxsize)}; } return $rstring; } This should yield a 6 char "random" string containing digits 0-9 and letters a-z. Good luck! -- Kim Christensen kim.christensen@gmail.com

« previous php.general (#230517) next »