diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper/CryptoProxy.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/CryptoProxy.php | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/CryptoProxy.php b/src/Wallabag/CoreBundle/Helper/CryptoProxy.php index e8b19cb9..7d8c9888 100644 --- a/src/Wallabag/CoreBundle/Helper/CryptoProxy.php +++ b/src/Wallabag/CoreBundle/Helper/CryptoProxy.php | |||
@@ -2,10 +2,10 @@ | |||
2 | 2 | ||
3 | namespace Wallabag\CoreBundle\Helper; | 3 | namespace Wallabag\CoreBundle\Helper; |
4 | 4 | ||
5 | use Psr\Log\LoggerInterface; | ||
6 | use Defuse\Crypto\Key; | ||
7 | use Defuse\Crypto\Crypto; | 5 | use Defuse\Crypto\Crypto; |
8 | use Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException; | 6 | use Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException; |
7 | use Defuse\Crypto\Key; | ||
8 | use Psr\Log\LoggerInterface; | ||
9 | 9 | ||
10 | /** | 10 | /** |
11 | * This is a proxy to crypt and decrypt password used by SiteCredential entity. | 11 | * This is a proxy to crypt and decrypt password used by SiteCredential entity. |
@@ -39,7 +39,7 @@ class CryptoProxy | |||
39 | */ | 39 | */ |
40 | public function crypt($secretValue) | 40 | public function crypt($secretValue) |
41 | { | 41 | { |
42 | $this->logger->debug('Crypto: crypting value: '.$this->mask($secretValue)); | 42 | $this->logger->debug('Crypto: crypting value: ' . $this->mask($secretValue)); |
43 | 43 | ||
44 | return Crypto::encrypt($secretValue, $this->loadKey()); | 44 | return Crypto::encrypt($secretValue, $this->loadKey()); |
45 | } | 45 | } |
@@ -53,12 +53,12 @@ class CryptoProxy | |||
53 | */ | 53 | */ |
54 | public function decrypt($cryptedValue) | 54 | public function decrypt($cryptedValue) |
55 | { | 55 | { |
56 | $this->logger->debug('Crypto: decrypting value: '.$this->mask($cryptedValue)); | 56 | $this->logger->debug('Crypto: decrypting value: ' . $this->mask($cryptedValue)); |
57 | 57 | ||
58 | try { | 58 | try { |
59 | return Crypto::decrypt($cryptedValue, $this->loadKey()); | 59 | return Crypto::decrypt($cryptedValue, $this->loadKey()); |
60 | } catch (WrongKeyOrModifiedCiphertextException $e) { | 60 | } catch (WrongKeyOrModifiedCiphertextException $e) { |
61 | throw new \RuntimeException('Decrypt fail: '.$e->getMessage()); | 61 | throw new \RuntimeException('Decrypt fail: ' . $e->getMessage()); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
@@ -81,6 +81,6 @@ class CryptoProxy | |||
81 | */ | 81 | */ |
82 | private function mask($value) | 82 | private function mask($value) |
83 | { | 83 | { |
84 | return strlen($value) > 0 ? $value[0].'*****'.$value[strlen($value) - 1] : 'Empty value'; | 84 | return strlen($value) > 0 ? $value[0] . '*****' . $value[strlen($value) - 1] : 'Empty value'; |
85 | } | 85 | } |
86 | } | 86 | } |