1 | <?php |
||
14 | class CryptKey |
||
15 | { |
||
16 | const RSA_KEY_PATTERN = |
||
17 | '/^(-----BEGIN (RSA )?(PUBLIC|PRIVATE) KEY-----\n)(.|\n)+(-----END (RSA )?(PUBLIC|PRIVATE) KEY-----)$/'; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $keyPath; |
||
23 | |||
24 | /** |
||
25 | * @var null|string |
||
26 | */ |
||
27 | protected $passPhrase; |
||
28 | |||
29 | /** |
||
30 | * @param string $keyPath |
||
31 | * @param null|string $passPhrase |
||
32 | */ |
||
33 | public function __construct($keyPath, $passPhrase = null) |
||
50 | |||
51 | /** |
||
52 | * @param string $key |
||
53 | * |
||
54 | * @throws \RuntimeException |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | private function saveKeyToFile($key) |
||
72 | |||
73 | /** |
||
74 | * Retrieve key path. |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | public function getKeyPath() |
||
82 | |||
83 | /** |
||
84 | * Retrieve key pass phrase. |
||
85 | * |
||
86 | * @return null|string |
||
87 | */ |
||
88 | public function getPassPhrase() |
||
92 | } |
||
93 |