Пример #1
0
 public static function encrypt($string, $key = '')
 {
     $encrypted = null;
     if (function_exists("mcrypt_generic") && mcrypt_module_self_test(MCRYPT_WAKE)) {
         $encrypted = jCrypt::mcryptEncrypt($string, $key);
     } else {
         $encrypted = jCrypt::simpleCrypt($string, $key);
     }
     return base64_encode($encrypted);
 }
Пример #2
0
 /**
  * Encrypt a string with a specific key
  * @param string $string the string to encrypt
  * @param string $key the key used to encrypt
  * @return string encrypted string
  */
 public static function encrypt($string, $key)
 {
     $encrypted = null;
     // Check if mcrypt is installed, and if WAKE algo exists
     if (function_exists("mcrypt_generic") && mcrypt_module_self_test(MCRYPT_WAKE)) {
         $encrypted = jCrypt::mcryptEncrypt($string, $key);
     } else {
         $encrypted = jCrypt::simpleCrypt($string, $key);
     }
     return base64_encode($encrypted);
 }