Пример #1
0
 /**
  * @covers CodeCollab\Encryption\Defusev2\Decryptor::__construct
  * @covers CodeCollab\Encryption\Defusev2\Decryptor::decrypt
  */
 public function testDecryptThrowsOnBadKey()
 {
     $encryptor = new Encryptor((new Key())->generate());
     $decryptor = new Decryptor((new Key())->generate());
     $this->expectException(FraudException::class);
     $decryptor->decrypt($encryptor->encrypt('foobar'));
 }
Пример #2
0
 /**
  * @covers CodeCollab\Encryption\Defusev2\Encryptor::__construct
  * @covers CodeCollab\Encryption\Defusev2\Encryptor::encrypt
  */
 public function testEncryptSuccess()
 {
     $encryptor = new Encryptor(DefuseKey::createNewRandomKey()->saveToAsciiSafeString());
     $this->assertSame(186, strlen($encryptor->encrypt('foobarbaz')));
 }