Skip to content

Commit

Permalink
Graceful decryption method
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Aug 26, 2016
1 parent f185c2e commit e1229bf
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use App\Models\Accessory;
use App\Models\Consumable;
use App\Models\Asset;
use Crypt;
use Illuminate\Contracts\Encryption\DecryptException;

/*
* To change this license header, choose License Headers in Project Properties.
Expand Down Expand Up @@ -476,6 +478,21 @@ public static function getLastDateFromHistoryArray(array $array)
}


public static function gracefulDecrypt(CustomField $field, $string) {

if ($field->isFieldDecryptable($string)) {

try {
Crypt::decrypt($string);
return Crypt::decrypt($string);

} catch (DecryptException $e) {
return 'Error Decrypting: '.$e->getMessage();
}

}
return $string;

}

}

0 comments on commit e1229bf

Please sign in to comment.