Update key.php

Switching from str_replace to preg_replace when generating the secure key so that a new one is generated even if there is already a key or it is an empty string.