function Decrypt($type, $data) { $algorithms = Encryption::listAlgorithms(); if (!array_key_exists ($type, $algorithms)) return false; $cipher = mcrypt_module_open(constant($algorithms[$type]), '', MCRYPT_MODE_CBC, ''); $k = Encryption::getKeys($cipher, $algorithms[$type]); if (mcrypt_generic_init($cipher, $k['key'], $k['iv']) != -1) { $cleanData = mdecrypt_generic($cipher, $data); mcrypt_generic_deinit($cipher); } mcrypt_module_close($cipher); return $cleanData; }