1. Go to this page and download the library: Download swissmakers/php-openssh 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/ */
swissmakers / php-openssh example snippets
use Swissmakers\OpenSSH\PrivateKey;
use Swissmakers\OpenSSH\PublicKey;
// Generate a new OpenSSH key pair
$privateKey = PrivateKey::generate();
$publicKey = $privateKey->getPublicKey();
// Encrypt and decrypt data using the key pair
$data = 'my secret data';
$encryptedData = $publicKey->encrypt($data); // Returns unreadable data
$decryptedData = $privateKey->decrypt($encryptedData); // Returns 'my secret data' in plaintext
use Swissmakers\OpenSSH\PrivateKey;
$privateKey = PrivateKey::generate();
$privateKey->toFile('/home/foo/bar');
use Swissmakers\OpenSSH\PrivateKey;
use Swissmakers\OpenSSH\PublicKey;
$privateKey = PrivateKey::fromFile($pathToPrivateKey);
$publicKey = PublicKey::fromFile($pathToPublicKey);
use Swissmakers\OpenSSH\PrivateKey;
use Swissmakers\OpenSSH\PublicKey;
$privateKey = PrivateKey::fromString($privateKeyContent);
$publicKey = PublicKey::fromString($publicKeyContent);
use Swissmakers\OpenSSH\PrivateKey;
$privateKey = PrivateKey::fromString($privateKeyContent);
$publicKey = $privateKey->getPublicKey();
use Swissmakers\OpenSSH\Rules\PublicKeyRule;
use Swissmakers\OpenSSH\Rules\PrivateKeyRule;
public function rules(): array
{
return [
'public_key' => [
new PublicKeyRule(),
],
'private_key' => [
new PrivateKeyRule(),
],
];
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.