Ejemplo n.º 1
0
 public function testEncryptDecryptChars()
 {
     $secret = '$%ÄüfuDFRR';
     $string = 'abcDEF012!"§$%&/()=?`´"\',.;:-_#+*~öäüÖÄÜ^°²³';
     $this->assertEquals(
         $string,
         HordeCipherBlowfishOperations::blowfishDecrypt(
             HordeCipherBlowfishOperations::blowfishEncrypt($string, $secret),
             $secret
         )
     );
 }
 /**
  * Decryption using blowfish algorithm (mcrypt)
  *
  * @param string $encdata encrypted data
  * @param string $secret  the secret
  *
  * @return string original data
  */
 public function blowfishDecrypt($encdata, $secret)
 {
     global $iv;
     if (!function_exists('mcrypt_encrypt')) {
         include_once "HordeCipherBlowfishOperations.class.php";
         return HordeCipherBlowfishOperations::blowfishDecrypt($encdata, $secret);
     }
     $data = base64_decode($encdata);
     $decrypted = mcrypt_decrypt(MCRYPT_BLOWFISH, $secret, $data, MCRYPT_MODE_CBC, $iv);
     return trim($decrypted);
 }