protected function doRun() { $cryptTool = CryptTool::getInstance(); $keyPair = $cryptTool->generateKeyPair(); $privateKeyHex = $cryptTool->bin2hex($keyPair->privateKey); $publicKeyHex = $cryptTool->bin2hex($keyPair->publicKey); file_put_contents($this->getArgument(self::argPrivateKeyFile), Common::convertPrivateKey($privateKeyHex) . "\n"); file_put_contents($this->getArgument(self::argPublicKeyFile), Common::convertPublicKey($publicKeyHex) . "\n"); Common::l('key pair generated'); }
/** * Unsets/removes a variable. * * Important: When using PHPv7, make sure to have at least version 1.0.1 of * the Libsodium PECL (libsodium-php) installed. Otherwise this falls back to * the (insecure) PHP method of removing a variable. * * @link https://paragonie.com/book/pecl-libsodium/read/03-utilities-helpers.md#memzero * @param string $var A variable, passed by reference */ public function removeVar(&$var) { // check if version is compatible if (version_compare(PHP_VERSION, '7.0', '>=') && version_compare(phpversion('libsodium'), '1.0.1', '<')) { // if not, fall back to PHP implementation return parent::removeVar($var); } /** @noinspection PhpUndefinedNamespaceInspection @noinspection PhpUndefinedFunctionInspection */ return \Sodium\memzero($var); }