Sure, but the point is that you may create duplicated keys, if creting them randomly.
Practically, I recommend to (unique) create random codes using the "access code" feature of SoSci Survey and copy them into a random generator.
Nonetheless, here's a little code to create random strings.
$length = 10;
$chars = '23456789ABCDEFGHKLMNPQRSTUVWXYZ';
$maxChar = strlen($chars)-1;
for ($i=0; $i<$length; $i++) {
$random = mt_rand(0, $maxChar); // Can also use: random(0, $maxChar)
$s.= $chars[$random];
}
html('<p>Code: '.$s.'</p>');
put('IV01_01', $s);