Skip to content

TroiaStudio/ssh-key-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ssh-key-validator

Usage

To install latest version of troia-studio/ssh-key-validator use Composer.

composer require troia-studio/ssh-key-validator

Supported Keys

  • DSS
  • ECDSA (and SK)
  • ED255 (and SK)
  • RSA

Examples

Validation

Use all validators

use TroiaStudio\SshKeyValidator\KeyValidator;

$keyValidator = KeyValidator::createAll();

$isValid = $keyValidator->validate('ssh-ed25519 BOOOM'); // return bool

Use specifics validators

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

Create Key object

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));

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published