PHP code example of troia-studio / ssh-key-validator

1. Go to this page and download the library: Download troia-studio/ssh-key-validator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

troia-studio / ssh-key-validator example snippets


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

use TroiaStudio\SshKeyValidator\KeyFactory;

$validators = [
    new RsaValidator(),
    new Ed25519Validator(),
];

$key = KeyFactory::create('ssh-ed25519 BOOOM'));
// Or
$key = KeyFactory::create('ssh-ed25519 BOOOM', $validators));