Skip to content

Commit e1ae379

Browse files
author
Muhammad Umer Farooq
authored
Update SodiumEncryption.php
1 parent b6e41ab commit e1ae379

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎src/Encryption/Adapter/SodiumEncryption.php‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@ class SodiumEncryption extends AbstractAdapter
2323
*
2424
* @since 3.0.0
2525
*/
26-
public function __construct()
26+
public function __construct($key = null)
2727
{
2828
if (!function_exists('sodium_crypto_secretbox_keygen')) {
2929
throw new \Exception('The sodium php extension does not installed or enabled', 500);
3030
}
3131

32-
if (isset(__config()->encryption->key) && strtolower(__config()->encryption->key) !== 'your-key') {
32+
if (null !== $key) {
3333

34-
//$this->key = sodium_crypto_secretbox_keygen();
3534
//Should use user define key.
36-
$this->key = substr(hash('sha512', __config()->encryption->key), 0, 32);
35+
$this->key = substr(hash('sha512', $key), 0, 32);
3736
} else {
3837
throw new \Exception('Crypto key not found', 500);
3938
}

0 commit comments

Comments
 (0)