/**
  * Encrypts hash γ same way as during ravel process to find corresponding message
  */
 public function prePhase(StashedDataPackage $stashedDataPackage)
 {
     $stashedDataPackage->setHashGamma($this->_hasher->hashSha($stashedDataPackage->getHashGamma()));
     $cipherCredentials = $this->_yamler->readCipherFile($fileName = $stashedDataPackage->getHashGamma());
     if (!$cipherCredentials) {
         return $stashedDataPackage->setError('UnravelFilter::prePhase - cipher file not found');
     }
     $this->_flashStorage->rememberCipherFileName($stashedDataPackage->getHashGamma());
     $this->_flashStorage->rememberCipherCredentials($cipherCredentials);
     $stashedDataPackage->setHashGamma($this->_cipher->encrypt($stashedDataPackage->getHashGamma(), $cipherCredentials['key'], $cipherCredentials['iv']));
     return $stashedDataPackage;
 }
 /**
  * @ORM\PrePersist
  *
  * Hashing and encrypting before persisting an entity
  */
 public function RavelPhase(StashedDataPackage $stashedDataPackage, LifecycleEventArgs $event)
 {
     $stashedDataPackage->setTimeOfDying();
     $stashedDataPackage->setData($this->_cipher->encrypt($stashedDataPackage->getData(), $stashedDataPackage->getHashBeta(), $stashedDataPackage->getSaltBeta()));
     $stashedDataPackage->setHashBeta($this->_hasher->hashBcrypt($stashedDataPackage->getHashBeta()));
     $stashedDataPackage->setHashGamma($this->_hasher->hashSha($stashedDataPackage->getHashGamma()));
     //Generate CSPRNG key and IV for cipher
     $cipherCredentials = ['key' => $this->_salter->getCSPRNG(32), 'iv' => $this->_salter->getCSPRNG(16)];
     //Write key and IV to a file named by sha512() from hash γ
     $this->_yamler->writeCipherFile($fileName = $stashedDataPackage->getHashGamma(), $cipherCredentials['key'], $cipherCredentials['iv']);
     $this->_yamler->setCipherFileName($fileName);
     $stashedDataPackage->setHashBeta($this->_cipher->encrypt($stashedDataPackage->getHashBeta(), $cipherCredentials['key'], $cipherCredentials['iv']));
     $stashedDataPackage->setHashGamma($this->_cipher->encrypt($stashedDataPackage->getHashGamma(), $cipherCredentials['key'], $cipherCredentials['iv']));
 }