17 lines
568 B
PHP
17 lines
568 B
PHP
<?php
|
|
namespace App\Helper;
|
|
|
|
class WGKey
|
|
{
|
|
static public function generatePrivateKeyForPeer() {
|
|
$folder = sys_get_temp_dir()."/".uniqid("wg-");
|
|
mkdir($folder);
|
|
exec("cd ".$folder."; wg genkey > privkey; cat privkey | wg pubkey > pubkey; wg genpsk > presharedkey");
|
|
|
|
$keys = [];
|
|
$keys["public"] = trim(file_get_contents($folder."/pubkey"));
|
|
$keys["privkey"] = trim(file_get_contents($folder."/privkey"));
|
|
$keys["presharedkey"] = trim(file_get_contents($folder."/presharedkey"));
|
|
return $keys;
|
|
}
|
|
}
|