fixing undefined variables : $c & $tmp

In function "generateKey"