You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use OpenSSL and Sodium encryption using the `Encryption` class:
156
+
157
+
```php
158
+
use SecurePassword\Encrypt\Encryption;
159
+
160
+
$encryption = new Encryption('your-key');
161
+
162
+
//Encrypt the message
163
+
$encrypt = $encryption->encrypt("This is a text");
164
+
165
+
echo $encrypt;
166
+
```
167
+
168
+
You can decrypt token by calling decrypt method:
169
+
170
+
```php
171
+
$encryption = new Encryption('your-key');
172
+
173
+
//Decrypt the message
174
+
$decrypt = $encryption->decrypt($encrypt);
175
+
176
+
echo $decrypt;
177
+
```
178
+
179
+
You can pass supported adapter to class like:
180
+
181
+
Use of OpenSSL
182
+
```php
183
+
$encryption = new Encryption(new OpenSslEncryption('your-key'));
184
+
```
185
+
Use of Sodium
186
+
```php
187
+
$encryption = new Encryption(new SodiumEncryption('your-key'));
188
+
```
189
+
190
+
Default openSSL will use, you can use any one you want.
191
+
153
192
## Changing the secret entry (recommended)
154
193
155
194
It is recommended to change the secret entry (or pepper) that will be added to your password. Use `setPepper` to change.
@@ -159,6 +198,16 @@ $password = new SecurePassword();
159
198
$password->setPepper('new_pepper');
160
199
```
161
200
201
+
By default, the `setPepper` method uses OpenSSL encryption. However, you can use Sodium encryption if you want.
202
+
203
+
```php
204
+
// Use OpenSSL
205
+
$password->setPepper('new_pepper', 'openssl');
206
+
207
+
// Use Sodium
208
+
$password->setPepper('new_pepper', 'sodium');
209
+
```
210
+
162
211
## Getting the ideal encryption cost
163
212
164
213
Here's a quick little function that will help you determine what cost parameter you should be using for your server to make sure you are within this range.
0 commit comments