To install latest version of troia-studio/ssh-key-validator
use Composer.
composer require troia-studio/ssh-key-validator
- DSS
- ECDSA (and SK)
- ED255 (and SK)
- RSA
use TroiaStudio\SshKeyValidator\KeyValidator;
$keyValidator = KeyValidator::createAll();
$isValid = $keyValidator->validate('ssh-ed25519 BOOOM'); // return bool
use TroiaStudio\SshKeyValidator\KeyValidator;
use TroiaStudio\SshKeyValidator\Validators\RsaValidator;
use TroiaStudio\SshKeyValidator\Validators\Ed25519Validator;
$validators = [
new RsaValidator(),
new Ed25519Validator(),
];
$keyValidator = new KeyValidator($validators);
$isValid = $keyValidator->validate('ssh-ed25519 BOOOM'); // return bool
Key object contains information like prefix
, type
, key
, and comment
.
When we before create, factory will check if key is valid.
use TroiaStudio\SshKeyValidator\KeyFactory;
$validators = [
new RsaValidator(),
new Ed25519Validator(),
];
$key = KeyFactory::create('ssh-ed25519 BOOOM'));
// Or
$key = KeyFactory::create('ssh-ed25519 BOOOM', $validators));