[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Traits/ -> PasswordProtected.php (source)

   1  <?php
   2  
   3  /**
   4   * Password Protected Trait for Private Keys
   5   *
   6   * PHP version 5
   7   *
   8   * @author    Jim Wigginton <terrafrost@php.net>
   9   * @copyright 2015 Jim Wigginton
  10   * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
  11   * @link      http://phpseclib.sourceforge.net
  12   */
  13  
  14  namespace phpseclib3\Crypt\Common\Traits;
  15  
  16  /**
  17   * Password Protected Trait for Private Keys
  18   *
  19   * @author  Jim Wigginton <terrafrost@php.net>
  20   */
  21  trait PasswordProtected
  22  {
  23      /**
  24       * Password
  25       *
  26       * @var string|bool
  27       */
  28      private $password = false;
  29  
  30      /**
  31       * Sets the password
  32       *
  33       * Private keys can be encrypted with a password.  To unset the password, pass in the empty string or false.
  34       * Or rather, pass in $password such that empty($password) && !is_string($password) is true.
  35       *
  36       * @see self::createKey()
  37       * @see self::load()
  38       * @param string|bool $password
  39       */
  40      public function withPassword($password = false)
  41      {
  42          $new = clone $this;
  43          $new->password = $password;
  44          return $new;
  45      }
  46  }