protected function doRun() { $privateKey = $this->getArgumentPrivateKey(self::argPrivateKey); Common::required($privateKey); $cryptTool = CryptTool::getInstance(); $publicKey = $cryptTool->derivePublicKey($privateKey); Common::l(Common::convertPublicKey($cryptTool->bin2hex($publicKey))); }
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'); }
protected function doRun() { $id = $this->getArgumentThreemaId(self::argThreemaId); $from = $this->getArgumentThreemaId(self::argFrom); $secret = $this->getArgument(self::argSecret); Common::required($id, $from, $secret); //define connection settings $settings = new ConnectionSettings($from, $secret); //create a connection $connector = new Connection($settings, $this->publicKeyStore); $result = $connector->fetchPublicKey($id); if ($result->isSuccess()) { Common::l(Common::convertPublicKey($result->getPublicKey())); } else { Common::e($result->getErrorMessage()); } }
public function testConvertPublicKey() { $p = Common::convertPublicKey('PUBKEYSTRING'); $this->assertEquals($p, 'public:PUBKEYSTRING', 'convertPublicKey failed'); }