コード例 #1
0
 /**
  * run the command
  */
 protected function doRun()
 {
     $privateKey = $this->getArgumentPrivateKey(self::argPrivateKey);
     $publicKey = $this->getArgumentPublicKey(self::argPublicKey);
     $textToEncrypt = $this->readStdIn();
     Common::required($privateKey, $publicKey, $textToEncrypt);
     $cryptTool = CryptTool::getInstance();
     //create a random nonce
     $newNonce = $cryptTool->randomNonce();
     $encryptedMessageText = $cryptTool->encryptMessageText($textToEncrypt, $privateKey, $publicKey, $newNonce);
     Common::ln($cryptTool->bin2hex($newNonce));
     //output encrypted text
     Common::ln($cryptTool->bin2hex($encryptedMessageText));
 }
コード例 #2
0
ファイル: Run.php プロジェクト: rugk/threema-msgapi-sdk-php
 private function help()
 {
     $defaultCryptTool = CryptTool::getInstance();
     Common::l();
     Common::l('Threema PHP MsgApi Tool');
     Common::l('Version: ' . MSGAPI_SDK_VERSION);
     Common::l('Feature level: ' . MSGAPI_FEATURE_LEVEL);
     Common::l('CryptTool: ' . $defaultCryptTool->getName() . ' (' . $defaultCryptTool->getDescription() . ')');
     Common::l(str_repeat('.', 40));
     Common::l();
     foreach ($this->commands as $data) {
         if (is_scalar($data)) {
             Common::l($data);
             Common::l(str_repeat('-', strlen($data)));
             Common::l();
         } else {
             list($key, $command) = $data;
             Common::ln($this->scriptName . ' ' . "" . implode(' ', $key) . "" . ' ' . $command->help());
             Common::l();
             /** @noinspection PhpUndefinedMethodInspection */
             Common::l($command->description(), 1);
             Common::l();
         }
     }
 }