un'altra interessante potrebbe essere:
Codice PHP:
function gen_pw ($len) {
    
$poss="01234567890abcdefghilmnopqrstuvzABCDEFGHILMNOPQRSTUVZ";
    
$pw "";
    for (
$i 0$i $len$i++) {
        
$char substr ($possrand (0strlen ($poss)), 1);
    
$pw .= $char;
    }
    return 
$pw;

nel tuo caso chiaramente richiamerai gen_pw (20)