Decrypt::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * @author Threema GmbH
4
 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
 */
6
7
8
namespace Threema\Console\Command;
9
10
use Threema\Console\Common;
11
use Threema\MsgApi\Tools\CryptTool;
12
13
class Decrypt extends Base {
14
	public function __construct() {
15
		parent::__construct('Decrypt',
16
			array(self::argPrivateKey, self::argPublicKey, self::argNonce),
17
			'Decrypt standard input using the given recipient private key and sender public key. The nonce must be given on the command line, and the box (hex) on standard input. Prints the decrypted message to standard output.');
18
	}
19
20 View Code Duplication
	protected function doRun() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
		$cryptTool = CryptTool::getInstance();
22
23
		$privateKey = $this->getArgumentPrivateKey(self::argPrivateKey);
24
		$publicKey = $this->getArgumentPublicKey(self::argPublicKey);
25
		$nonce = $cryptTool->hex2bin($this->getArgument(self::argNonce));
26
		$input = $cryptTool->hex2bin($this->readStdIn());
27
28
		Common::required($privateKey, $publicKey, $nonce, $input);
29
		$cryptTool = CryptTool::getInstance();
30
		$message = $cryptTool->decryptMessage($input, $privateKey, $publicKey, $nonce);
31
32
		Common::l((String)$message);
33
	}
34
}
35