.htaccess
1 year ago
Fingerprint.php
1 year ago
PasswordProtected.php
1 year ago
index.html
1 year ago
web.config
1 year ago
PasswordProtected.php
48 lines
| 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 | declare(strict_types=1); |
| 15 | |
| 16 | namespace phpseclib3\Crypt\Common\Traits; |
| 17 | |
| 18 | /** |
| 19 | * Password Protected Trait for Private Keys |
| 20 | * |
| 21 | * @author Jim Wigginton <terrafrost@php.net> |
| 22 | */ |
| 23 | trait PasswordProtected |
| 24 | { |
| 25 | /** |
| 26 | * @var string|null |
| 27 | */ |
| 28 | private $password = null; |
| 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 | * |
| 39 | * @return static |
| 40 | */ |
| 41 | public function withPassword(?string $password = null): self |
| 42 | { |
| 43 | $new = clone $this; |
| 44 | $new->password = $password; |
| 45 | return $new; |
| 46 | } |
| 47 | } |
| 48 |