Customcert verification code - limit characters

Re: Customcert verification code - limit characters

by Simon Harvey -
Number of replies: 0
I've answered my own question.

I've copied the function random_string () in /lib/moodlelib.php so that it doesn't use the characters

function random_string_cert($length=15) {
    $randombytes = random_bytes_emulate($length);
    $pool  = 'ABCDEFGHJKLMNPQRSTVWXYZ';
    $pool .= 'abcdefghijkmnpqrstvwxyz';
    $pool .= '123456789';
    $poollen = strlen($pool);
    $string = '';
    for ($i = 0; $i < $length; $i++) {
        $rand = ord($randombytes[$i]);
        $string .= substr($pool, ($rand%($poollen)), 1);
    }
    return $string;
}


and then called this new function in /mod/customcert/classes/certificate.php