public static hasPassphrase ( string $keyFile ) : boolean | ||
$keyFile | string | SSH key file data |
Результат | boolean |
public static function hasPassphrase($keyFile)
{
if (preg_match("/Proc-Type.+ENCRYPTED/", $keyFile) === 1) {
return true;
} else {
return false;
}
}
public function testHasPassphrase() { $ret = SSHKey::hasPassphrase(file_get_contents(__DIR__ . "/../../keys/id_rsa_nopass")); $this->assertEquals(false, $ret); $ret = SSHKey::hasPassphrase(file_get_contents(__DIR__ . "/../../keys/id_rsa_pass")); $this->assertEquals(true, $ret); }