Código PHP:
<?php
function gen_rand_string()
{
$chars = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', '1', '2', '3', '4', '5',
'6', '7', '8', '9', '0');
$max_chars = count($chars) - 1;
srand((double) microtime()*1000000);
$rand_str = '';
for($i=0; $i < 8; $i++)
{
$rand_str = $rand_str . $chars[rand(0, $max_chars)];
}
return $rand_str;
}
?>
Pieza de codigo tomada de PHPbb
tambien puedes darle un MD5()
lego str_shuffle()
leugo
substr($str,0,12); o algo asi :)
cheka aqui para ver mas funciones de manejo de string
http://mx2.php.net/manual/en/ref.strings.php