public function testEncryptImage() { $threemaIconContent = file_get_contents(dirname(__FILE__) . '/threema.jpg'); /** @noinspection PhpUnusedParameterInspection */ $this->doTest(function (CryptTool $cryptTool, $prefix) use($threemaIconContent) { $privateKey = $cryptTool->hex2bin(Common::getPrivateKey(Constants::myPrivateKey)); $publicKey = $cryptTool->hex2bin(Common::getPublicKey(Constants::myPublicKey)); $otherPrivateKey = $cryptTool->hex2bin(Common::getPrivateKey(Constants::otherPrivateKey)); $otherPublicKey = $cryptTool->hex2bin(Common::getPublicKey(Constants::otherPublicKey)); $result = $cryptTool->encryptImage($threemaIconContent, $privateKey, $otherPublicKey); $decryptedImage = $cryptTool->decryptImage($result->getData(), $publicKey, $otherPrivateKey, $result->getNonce()); $this->assertEquals($decryptedImage, $threemaIconContent, 'decryption of image failed'); }); }
public function testGetPrivateKey() { $realPrivateKey = Common::getPrivateKey(Constants::myPrivateKey); $this->assertEquals($realPrivateKey, Constants::myPrivateKeyExtract, 'getPrivateKey failed'); }
/** * @param string $pos * @return null|string */ public function getArgumentPrivateKey($pos) { $content = Common::getPrivateKey($this->getArgumentStringOrFileContent($pos)); $cryptTool = CryptTool::getInstance(); if (null !== $content) { return $cryptTool->hex2bin($content); } return null; }