10
10
11
11
namespace Sidus \EncryptionBundle \Manager ;
12
12
13
- use Exception ;
14
13
use Sidus \EncryptionBundle \Encryption \EncryptionAdapterInterface ;
15
14
use Sidus \EncryptionBundle \Entity \UserEncryptionProviderInterface ;
16
15
use Sidus \EncryptionBundle \Exception \EmptyCipherKeyException ;
@@ -101,16 +100,7 @@ public function encryptString(string $string, string $nonce = null): string
101
100
if (null === $ nonce ) {
102
101
$ nonce = $ this ->encryptionAdapter ->generateNonce ();
103
102
}
104
-
105
- try {
106
- $ encrypted = $ this ->encryptionAdapter ->encrypt ($ string , $ nonce , $ this ->cipherKeyStorage ->getCipherKey ());
107
- } catch (Exception $ exception ) {
108
- if ($ this ->throwExceptions ) {
109
- throw $ exception ;
110
- }
111
-
112
- return '' ;
113
- }
103
+ $ encrypted = $ this ->encryptionAdapter ->encrypt ($ string , $ nonce , $ this ->cipherKeyStorage ->getCipherKey ());
114
104
115
105
return $ nonce .$ encrypted ;
116
106
}
@@ -125,22 +115,14 @@ public function decryptString(string $encryptedString, string $nonce = null): st
125
115
return '' ;
126
116
}
127
117
128
- try {
129
- if ($ nonce === null ) {
130
- $ nonce = $ this ->encryptionAdapter ->parseNonce ($ encryptedString );
131
- }
132
- $ decrypted = $ this ->encryptionAdapter ->decrypt (
133
- $ encryptedString ,
134
- $ nonce ,
135
- $ this ->cipherKeyStorage ->getCipherKey ()
136
- );
137
- } catch (Exception $ exception ) {
138
- if ($ this ->throwExceptions ) {
139
- throw $ exception ;
140
- }
141
-
142
- return '' ;
118
+ if ($ nonce === null ) {
119
+ $ nonce = $ this ->encryptionAdapter ->parseNonce ($ encryptedString );
143
120
}
121
+ $ decrypted = $ this ->encryptionAdapter ->decrypt (
122
+ $ encryptedString ,
123
+ $ nonce ,
124
+ $ this ->cipherKeyStorage ->getCipherKey ()
125
+ );
144
126
145
127
return rtrim ($ decrypted , "\0" );
146
128
}
0 commit comments