Skip to content

Commit 03082c6

Browse files
committed
docs: deprecate random_string() basic,md5,sha1
1 parent 10e3300 commit 03082c6

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

system/Helpers/text_helper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ function reduce_multiples(string $str, string $character = ',', bool $trim = fal
538538
*
539539
* @param string $type Type of random string. basic, alpha, alnum, numeric, nozero, md5, sha1, and crypto
540540
* @param int $len Number of characters
541+
*
542+
* @deprecated The type 'basic', 'md5', and 'sha1' are deprecated. They are not cryptographically secure.
541543
*/
542544
function random_string(string $type = 'alnum', int $len = 8): string
543545
{

user_guide_src/source/changelogs/v4.3.4.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Changes
2121
Deprecations
2222
************
2323

24+
- **Text Helper:** :php:func:`random_string()`'s type ``basic``, ``md5``, and
25+
``sha1`` are deprecated. They are not cryptographically secure.
26+
2427
Bugs Fixed
2528
**********
2629

user_guide_src/source/helpers/text_helper.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,18 @@ The following functions are available:
3333
.. warning:: For types: **basic**, **md5**, and **sha1**, generated strings
3434
are not cryptographically secure. Therefore, these types cannot be used
3535
for cryptographic purposes or purposes requiring unguessable return values.
36+
Since v4.3.3, these types are deprecated.
3637

3738
The first parameter specifies the type of string, the second parameter
3839
specifies the length. The following choices are available:
3940

4041
- **alpha**: A string with lower and uppercase letters only.
4142
- **alnum**: Alphanumeric string with lower and uppercase characters.
42-
- **basic**: A random number based on ``mt_rand()`` (length ignored).
43+
- **basic**: [deprecated] A random number based on ``mt_rand()`` (length ignored).
4344
- **numeric**: Numeric string.
4445
- **nozero**: Numeric string with no zeros.
45-
- **md5**: An encrypted random number based on ``md5()`` (fixed length of 32).
46-
- **sha1**: An encrypted random number based on ``sha1()`` (fixed length of 40).
46+
- **md5**: [deprecated] An encrypted random number based on ``md5()`` (fixed length of 32).
47+
- **sha1**: [deprecated] An encrypted random number based on ``sha1()`` (fixed length of 40).
4748
- **crypto**: A random string based on ``random_bytes()``.
4849

4950
.. note:: When you use **crypto**, you must set an even number to the second parameter.

0 commit comments

Comments
 (0)