Skip to content

Commit

Permalink
generate truly random secret keys.
Browse files Browse the repository at this point in the history
The plugin requires PHP7.3 and random_bytes is available in PHP7.0
  • Loading branch information
calvinalkan committed Dec 18, 2023
1 parent 94cea3d commit 93c0eb6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use FluentSnippets\App\Services\PhpValidator;

use function bin2hex;
use function random_bytes;

class Helper
{
public static function getStorageDir()
Expand Down Expand Up @@ -47,14 +50,14 @@ public static function cacheSnippetIndex($fileName = '', $isForced = false, $ext
'remove_on_uninstall' => 'no',
'force_disabled' => 'no',
'legacy_status' => 'new',
'secret_key' => md5(wp_generate_uuid4() . time() . random_int(1000, 10000))
'secret_key' => bin2hex(random_bytes(16))
],
'error_files' => []
];
}

if (empty($previousConfig['meta']['secret_key'])) {
$previousConfig['meta']['secret_key'] = md5(wp_generate_uuid4() . time() . random_int(1000, 10000));
$previousConfig['meta']['secret_key'] = bin2hex(random_bytes(16));
}

$data['meta'] = [
Expand Down

0 comments on commit 93c0eb6

Please sign in to comment.