eldorado
Involved
Joined: Sep 10, 2008
Posts: 424
Location: France,Translator
|
Posted:
Thu Jun 11, 2009 11:13 am |
|
Just want to know if the captcha system will be improved?
I hear a lot about randomness nowadays , even about entropia. Just an interresting article I read.
[ Only registered users can see links on this board! Get registered or login! ]
I just thought of it because when I was typing numbers in the captcha I got the same number appearing in a tooltip (I'm using chrome)
Don't want to read , here it is Code:function phptalk_rand($bytes)
{
// If OpenSSL random function is supported, we will use it
if (function_exists('openssl_random_pseudo_bytes'))
$rand = openssl_random_pseudo_bytes($bytes);
// If we are on Sun Solaris / Unix / Linux this should work
if (strlen($rand) < $bytes && ($handle = @fopen('/dev/urandom','rb')))
{
$rand = fread($handle,$bytes);
fclose($handle);
}
// If both failed, let's try Microsoft's CSP
if (strlen($rand) < $bytes && class_exists('COM'))
{
$capi = new COM('CAPICOM.Utilities.1');
$random = substr(base64_decode($capi -> getrandom($bytes,0)),0,$bytes);
unset($capi);
}
// Everything failed?!
if (strlen($rand) < $bytes)
{
$rand = '';
for ($a = 0;$a < $bytes;$a += 16)
{
$rand .= pack('H*',md5(mt_rand().microtime(true).uniqid('',true).join('',stat(__FILE__)).memory_get_usage().getmypid()));
}
$rand = substr($rand,0,$bytes);
}
return $rand;
}
|
or this one if the above doesn't work
Code:$random = mt_rand().microtime(true).uniqid('',true).join('',stat(__FILE__)).memory_get_usage().getmypid();
$random = md5($random);
$random = base_convert($random,16,10);
$random = (double) substr($random,0,13)+(double) substr($random,14,13);
|
|
|
|
jakec
Site Admin
Joined: Feb 06, 2006
Posts: 3048
Location: United Kingdom
|
Posted:
Thu Jun 11, 2009 12:24 pm |
|
The use of letters is better because the number of possible combinations is greater and therefore less likely to be displayed more than once.
Sorry not technically related to your post, but because you mentioned numbers I thought I would mention it. |
|
|