Your missing the $key
variable inside the function body. With the correct error level settings you'd have been given a warning, that $key
is undefined.
Either add $key
as a function argument or define $key
inside the function body (or, third alternative, import $key
from the global scope).
1
function decrypt($user, $key){
//...
}
2
function decrypt($user){
$key = '....whatever...';
//...
}
3.1
function decrypt($user){
global $key;
//...
}
3.2
function decrypt($user){
//...
$user = mcrypt_ecb(MCRYPT_DES, $GLOBALS['key'], $user, MCRYPT_DECRYPT);
//...
}