Skip to content

Commit

Permalink
Make decryption return a value.
Browse files Browse the repository at this point in the history
  • Loading branch information
JASchilz committed Nov 24, 2015
1 parent 2dc3e1b commit 78eb5f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/EncryptionBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ protected function modifyGetterWithDecryption(&$script, $columnPhpName) {
protected function decryptVariable($variableName) {
return <<<EOT
// Decrypt the variable, per \UWDOEM\Encryption\EncryptionBehavior.
$variableName = \UWDOEM\Encryption\Cipher::getInstance()->decryptStream($variableName);
\$fieldValue = $variableName;
if (is_resource(\$fieldValue) && get_resource_type(\$fieldValue) === "stream") {
\$fieldValue = \UWDOEM\Encryption\Cipher::getInstance()->decryptStream(\$fieldValue);
}
return \$fieldValue;
EOT;
}

Expand Down
6 changes: 5 additions & 1 deletion tests/BehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ public function setVarBinaryColumn1($v)
public function getVarBinaryColumn1()
{
// Decrypt the variable, per \UWDOEM\Encryption\EncryptionBehavior.
$this->test_column = \UWDOEM\Encryption\Cipher::getInstance()->decryptStream($this->test_column);
$fieldValue = $this->test_column;
if (is_resource($fieldValue) && get_resource_type($fieldValue) === "stream") {
$fieldValue = \UWDOEM\Encryption\Cipher::getInstance()->decryptStream($fieldValue);
}
return $fieldValue;
}
public function setVarBinaryColumn1($v)
Expand Down

0 comments on commit 78eb5f9

Please sign in to comment.