From df790e0c9adcd8bfcf1e2cdb007645e536ef67a5 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Sat, 21 Aug 2021 21:48:33 +0200 Subject: [PATCH] feat(Random): add hex characters set --- modules/random/random.php | 2 +- modules/random/random_help.php | 4 ++++ utils.php | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/random/random.php b/modules/random/random.php index 00a5f40..49867dc 100644 --- a/modules/random/random.php +++ b/modules/random/random.php @@ -2,7 +2,7 @@ $len = $_GET['length'] ?? 32; -$contains = isset($_GET['contains']) ? explode(',', $_GET['contains']) : ['digit', 'upper', 'lower', 'special']; +$contains = isset($_GET['contains']) ? explode(',', $_GET['contains']) : ['hex', 'digit', 'upper', 'lower', 'special']; header('Content-Type: text/plain'); diff --git a/modules/random/random_help.php b/modules/random/random_help.php index 4923311..a2870d3 100644 --- a/modules/random/random_help.php +++ b/modules/random/random_help.php @@ -13,6 +13,10 @@ return [ [ 'name' => 'Change length', 'path' => '/?length=20' + ], + [ + 'name' => 'Only hex', + 'path' => '/?length=16&contains=hex' ] ], 'append' => function () { diff --git a/utils.php b/utils.php index ed66647..15a690f 100644 --- a/utils.php +++ b/utils.php @@ -5,7 +5,8 @@ function generateRandomString($length = 10, $contains = ['upper', 'lower', 'digi 'digit' => '0123456789', 'lower' => 'abcdefghijklmnopqrstuvwxyz', 'upper' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', - 'special' => '!#$%&()*+,-.:;<=>?@[]' + 'special' => '!#$%&()*+,-.:;<=>?@[]', + 'hex' => '0123456789abcdef' ]; $characters = ''; foreach ($contains as $c) {