Example #1
0
 /**
  * @param string $data
  * @param string $key
  * @param CipherParamsInterface $cipherParams
  * @return string
  */
 public function decrypt($data, $key, CipherParamsInterface $cipherParams)
 {
     if ($cipherParams instanceof AesParams) {
         return $this->aes->decrypt($data, $key, $cipherParams);
     }
     throw new \RuntimeException('Unknown or unsupported cipher');
 }
Example #2
0
 public function testConsistency()
 {
     $data = 'This is a secret message';
     $factory = new AesFactory();
     $params = $factory->aes256();
     $crypter = new AesCrypt();
     $privKey = str_repeat('A', 32);
     $cipherText = $crypter->encrypt($data, $privKey, $params);
     $plainText = $crypter->decrypt($cipherText, $privKey, $params);
     $this->assertEquals($data, $plainText);
 }