protected function doRun() { $email = $this->getArgument(self::argEmail); Common::required($email); $hashedEmail = CryptTool::getInstance()->hashEmail($email); Common::l($hashedEmail); }
protected function doRun() { $phoneNo = $this->getArgument(self::argPhoneNo); Common::required($phoneNo); $hashedPhoneNo = CryptTool::getInstance()->hashPhoneNo($phoneNo); Common::l($hashedPhoneNo); }
protected function doRun() { $cryptTool = CryptTool::getInstance(); $sendersThreemaId = $this->getArgumentThreemaId(self::argThreemaId); $id = $this->getArgumentThreemaId(self::argFrom); $secret = $this->getArgument(self::argSecret); $privateKey = $this->getArgumentPrivateKey(self::argPrivateKey); $nonce = $cryptTool->hex2bin($this->getArgument(self::argNonce)); $messageId = $this->getArgument(self::argMessageId); $outputFolder = $this->getArgument(self::argOutputFolder); $box = $cryptTool->hex2bin($this->readStdIn()); Common::required($box, $id, $secret, $privateKey, $nonce); $settings = new ConnectionSettings($id, $secret); $connector = new Connection($settings, $this->publicKeyStore); $helper = new E2EHelper($privateKey, $connector); $message = $helper->receiveMessage($sendersThreemaId, $messageId, $box, $nonce, $outputFolder); if (null === $message) { Common::e('invalid message'); return; } if ($message->isSuccess()) { Common::l($message->getMessageId() . ' - ' . $message->getThreemaMessage()); foreach ($message->getFiles() as $fileName => $filePath) { Common::l(' received file ' . $fileName . ' in ' . $filePath); } } else { Common::e('Error: ' . implode("\n", $message->getErrors())); } }
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))); }
/** * @return array */ public function getParams() { $cryptTool = CryptTool::getInstance(); $p['to'] = $this->threemaId; $p['nonce'] = $cryptTool->bin2hex($this->getNonce()); $p['box'] = $cryptTool->bin2hex($this->getBox()); return $p; }
/** * @param string $privateKey (binary) * @param Connection $connection * @param CryptTool $cryptTool */ public function __construct($privateKey, Connection $connection, CryptTool $cryptTool = null) { $this->connection = $connection; $this->cryptTool = $cryptTool; $this->privateKey = $privateKey; if (null === $this->cryptTool) { $this->cryptTool = CryptTool::getInstance(); } }
/** * Convert to string * * @return string */ public function __toString() { $cryptTool = CryptTool::getInstance(); $str = "Delivery receipt (" . $this->getReceiptTypeName() . "): "; $hexMessageIds = array(); foreach ($this->ackedMessageIds as $messageId) { $hexMessageIds[] = $cryptTool->bin2hex($messageId); } $str .= join(", ", $hexMessageIds); return $str; }
protected function doRun() { $cryptTool = CryptTool::getInstance(); Common::l('Version: ' . MSGAPI_SDK_VERSION); Common::l('Feature level: ' . MSGAPI_SDK_FEATURE_LEVEL); Common::l('CryptTool: ' . $cryptTool->getName() . ' (' . $cryptTool->getDescription() . ')'); Common::l(' ╔═══════╤══════╤══════════════╤═══════╤══════╤═════════╗'); Common::l(' ║ Level │ Text │ Capabilities │ Image │ File │ Credits ║'); Common::l(' ╟───────┼──────┼──────────────┼───────┼──────┼─────────╢'); Common::l(' ║ 1 │ X │ │ │ │ ║'); Common::l(' ║ 2 │ X │ X │ X │ X │ ║'); Common::l("[1;36m[40m▶" . '║ 3 │ X │ X │ X │ X │ X ║' . "[0m"); Common::l(' ╚═══════╧══════╧══════════════╧═══════╧══════╧═════════╝'); }
/** * 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)); }
/** * @return string */ public function getPath() { return 'lookup/phone_hash/' . urlencode(CryptTool::getInstance()->hashPhoneNo($this->phoneNumber)); }
/** * @return string */ public function getPath() { return 'lookup/email_hash/' . urlencode(CryptTool::getInstance()->hashEmail($this->emailAddress)); }
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 . ' ' . "[1;33m" . implode(' ', $key) . "[0m" . ' ' . $command->help()); Common::l(); /** @noinspection PhpUndefinedMethodInspection */ Common::l($command->description(), 1); Common::l(); } } }