Generate Serial numbers. This tool can generate up to 250,000 unique random codes at a time. Not logged in, it's limited to 1000 codes per batch. If you own a Random Code Generator account, it can generate an unlimited amount of codes in batches of 250.000 each! The generated codes can be used for passwords, promotional codes, sweepstakes, serial numbers and much more. Sep 07, 2016 Generate a random string of specified length. This uses the supplied character list for generating the new result string. The list of characters should be specified as a string containing each allowed character.
A fluent PHP random key generator.
Keygen is a PHP package that generates random character sequences known as keys. The package ships with built-in key generators for four key types namely: numeric, alphanumeric, token and byte. Its implementation effectively combines simplicity and expressiveness.
The Keygen package can be installed easily with [Composer] - require the gladcodes/keygen
package from the command line.
Alternatively, you can manually add the Keygen package to the composer.json
file of your project and then run composer install
from the command line as follows:
You can use it in your PHP code like this:
The Keygen package is covered by the MIT
License.
This is a short guide on how to generate a random token with PHP. These kind of tokens are used for a number of different reasons:
A lot of people make the mistake of using the function rand or mt_rand in correlation with a hashing function such as md5 or sha1:
The problem with the approach above is that the token will NOT be cryptographically secure.
To generate a cryptographically secure token in PHP, you will need to use the openssl_random_pseudo_bytes function: