/**
  * Boots the Bundle.
  */
 public function boot()
 {
     if ($this->container->hasParameter('rafrsr.doctrine.encryptor')) {
         $encryptor = $this->container->getParameter('rafrsr.doctrine.encryptor');
     } else {
         $encryptor = MCRYPT_RIJNDAEL_256;
     }
     if ($this->container->hasParameter('rafrsr.doctrine.secret')) {
         $secret = $this->container->getParameter('rafrsr.doctrine.secret');
     } else {
         $secret = $this->container->getParameter('secret');
     }
     Encryptor::set(Crypto::build($secret, $encryptor));
 }
Ejemplo n.º 2
0
 public function testBuildCustomEncryptor()
 {
     $message = 'This is a secret message';
     $encryptor = Crypto::build('1234', 'Rafrsr\\Crypto\\Tests\\CustomEncryptor');
     $encrypted = $encryptor->encrypt($message);
     $this->assertNotEquals($message, $encrypted);
     //avoid double encryption
     $this->assertEquals($encrypted, $encryptor->encrypt($encrypted));
     $this->assertTrue($encryptor->isEncrypted($encrypted));
     $decrypted = $encryptor->decrypt($encrypted);
     $this->assertEquals($message, $decrypted);
     //avoid double decryption
     $this->assertEquals($decrypted, $encryptor->decrypt($decrypted));
     $this->assertFalse($encryptor->isEncrypted($decrypted));
 }