[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/horde/framework/Horde/Crypt/Blowfish/ -> Openssl.php (source)

   1  <?php
   2  /**
   3   * Copyright 2012-2014 Horde LLC (http://www.horde.org/)
   4   *
   5   * See the enclosed file COPYING for license information (LGPL). If you
   6   * did not receive this file, see http://www.horde.org/licenses/lgpl21.
   7   *
   8   * @category  Horde
   9   * @copyright 2012-2014 Horde LLC
  10   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  11   * @package   Crypt_Blowfish
  12   */
  13  
  14  /**
  15   * Openssl driver for blowfish encryption.
  16   *
  17   * @author    Michael Slusarz <slusarz@horde.org>
  18   * @category  Horde
  19   * @copyright 2012-2014 Horde LLC
  20   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  21   * @package   Crypt_Blowfish
  22   */
  23  class Horde_Crypt_Blowfish_Openssl extends Horde_Crypt_Blowfish_Base
  24  {
  25      /**
  26       */
  27      static public function supported()
  28      {
  29          return extension_loaded('openssl');
  30      }
  31  
  32      /**
  33       */
  34      public function encrypt($text)
  35      {
  36          if (PHP_VERSION_ID <= 50302) {
  37              return @openssl_encrypt($text, 'bf-' . $this->cipher, $this->key, true);
  38          } elseif (PHP_VERSION_ID == 50303) {
  39              // Need to mask error output, since an invalid warning message was
  40              // issued prior to 5.3.4 for empty IVs in ECB mode.
  41              return @openssl_encrypt($text, 'bf-' . $this->cipher, $this->key, true, strval($this->iv));
  42          }
  43  
  44          return openssl_encrypt($text, 'bf-' . $this->cipher, $this->key, true, strval($this->iv));
  45      }
  46  
  47      /**
  48       */
  49      public function decrypt($text)
  50      {
  51          return (PHP_VERSION_ID <= 50302)
  52              ? openssl_decrypt($text, 'bf-' . $this->cipher, $this->key, true)
  53              : openssl_decrypt($text, 'bf-' . $this->cipher, $this->key, true, strval($this->iv));
  54      }
  55  
  56  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1