I have a repeated function in a couple of my models that all it does is generate a random salt string. Instead of repeating this code in each of the models that requires a generated salt, should i create this as a component or widget or module?
Here is the actual function;
private function randomSalt($length)
{
$chars = "abcdefghijkmnopqrstuvwxyz023456789";
srand((double)microtime()*1000000);
$i = 0;
$salt = '' ;
while ($i < $length)
{
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$salt .= $tmp;
$i++;
}
return $salt;
}