Skip to content

Instantly share code, notes, and snippets.

@AndreiTelteu
Created September 26, 2019 09:12
Show Gist options
  • Save AndreiTelteu/4b4b6843bbd15d50d3b0e91f98c18188 to your computer and use it in GitHub Desktop.
Save AndreiTelteu/4b4b6843bbd15d50d3b0e91f98c18188 to your computer and use it in GitHub Desktop.
<?php
// install composer require phpseclib/phpseclib:~2.0
// https://github.com/phpseclib/phpseclib
$rsa = new \phpseclib\Crypt\RSA();
$rsa->setPassword($password);
$rsa->setPrivateKeyFormat(\phpseclib\Crypt\RSA::PUBLIC_FORMAT_OPENSSH);
$rsa->setPublicKeyFormat(\phpseclib\Crypt\RSA::PUBLIC_FORMAT_OPENSSH);
$rsa->setComment('robot@laravel.com');
$keys = $rsa->createKey(4096);
$publicKey = $keys['publickey'];
$privateKey = $keys['privatekey'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment