Download the PHP package forever2077/php-random-string without Composer
On this page you can find all versions of the php package forever2077/php-random-string. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-random-string
Random string generator for PHP 8.0
This package can be used to generate a random string based on your set of characters or predefined ones. You can configure string length, prefix, suffix, and count of strings, or skip some strings under certain conditions...
Installation
You can install the package via composer:
Usage
Basic
Simple example without any configuration.
Length definition
You can control the length of the string. By default, it's 16 characters.
`
Predefined charset
If you want to generate a string consisting of numbers only, lowercase letters, or uppercase letters you can use predefined charsets.
Custom charset
Or you can use your custom charset for generating random string.
Skipping
Sometimes you may want to generate a random string but under certain conditions. For example, give me a string that is not part of this array.
Prefix and Suffix
If you want to add a prefix or suffix to generated string, you can do it like this.
Array of random strings
RandomString
can generate more than just one string.
Uniqueness
It may happen (rarely, but it's possible) to have not unique strings in the generated array. If you want to avoid it, just change the config.
Everything in one line
You can use the fromArray
method if you don't want to create 2 objects every time.
Testing
Security
While the RandomString
class is designed to generate random and unpredictable string, it is important to note that it is not a cryptographically secure hash function and should not be used for sensitive applications such as password hashing or cryptographic key generation.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
- Stefan Damjanovic
- All Contributors
License
The MIT License (MIT). Please see License File for more information.