Well, it looks like I've finally managed to end the world. I'm trying to use an encryption function that I have had lying around when attempting to use it, I get the following error:
Warning: in file file.php on line 1457: Division by zero
The function:
$enckey = 'NotTheRealEncKey';
function encrypt($string, $enckey) {
$result = '';
for($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($enckey, ($i % strlen($enckey))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}
return base64_encode($result);
}
The line in question is:
$keychar = substr($enckey, ($i % strlen($enckey))-1, 1);
and the string getting encrypted(it's a randomly generated token:
I've been googling but I'm coming up empty. Could someone perhaps set me on the path to righteousness by telling me what I'm doing wrong?
Thanks for your time!