Install the complete package with local command reference and every published mode.
install randrandNeed a fresh token, unpredictable number or unique-looking identifier?
Use -b for cryptographically random bytes encoded as hex, -s for an alphanumeric string and -uuid for a version 4 UUID. A UUID is useful as an identifier, not as a secret. In the examples below the displayed values are samples; every normal invocation generates different output.
Secure integers, bytes and strings use the cryptographic random source. A UUID is designed as an identifier, not a secret, and -mt can be reproducible when seeded, so MT output must not be used for passwords, access tokens or cryptographic keys.
rand [min [max]]randgenerate a cryptographic integer from 0 to PHP_INT_MAX
rand <max>generate a cryptographic integer from 0 to max
rand <min> <max>generate a cryptographic integer in the selected range
rand -n <count> [min] [max]generate several integers
rand -b <bytes>generate cryptographic random bytes as hexadecimal
rand -s <length>generate a cryptographic alphanumeric string
rand -uuidgenerate an RFC 4122 version 4 UUID
rand -mt [min] [max]generate a fast non-cryptographic integer
rand -mt -seed <integer>seed the MT generator before generation
rand -maxshow integer generator limits
Minimum generates one integer with up to two bounds; -n, -s, -b, UUID and MT require Base.
Run the prepared examples directly on the page. Their results are prebuilt and shown in the browser; no terminal command is executed on the server.
Install the current compatible version. Choose Base for the complete feature set or Minimum for the reduced package; use upgrade to update a module that is already installed.
Base and Minimum are two packages of the same current module release, not separate command versions.
Install the complete package with local command reference and every published mode.
install randInstall the reduced package. Local reference is omitted;
install rand -mInstall exactly this published version.
install rand -v 1.1.2Ask upgrade to check compatibility and replace the installed block only when needed.
upgrade randRemove the extension block while leaving the core and unrelated modules intact.
install rand -uExamples are copyable command lines, not actions executed by this website. Review paths, permissions and destructive flags before running them on a real project.
randSample output (a new value is generated on each run):
6717973524709714206rand 100Sample output (a new value is generated on each run):
75rand 10 20Sample output (a new value is generated on each run):
13rand -5 5Sample output (a new value is generated on each run):
5rand -n 5 1 10Sample output (a new value is generated on each run):
7
3
10
6
4rand -n 3Sample output (a new value is generated on each run):
191285834354115477
5305755011603380746
6738832702881509879rand -b 16Sample output (a new value is generated on each run):
439cce918df83a95d1d5ef3787e88e77rand -b 32Sample output (a new value is generated on each run):
2e31f17f5df14c264cf41cba1aa730a0405983ce0580f615302717c97d37acf4rand -s 24Sample output (a new value is generated on each run):
RH0xmptLqFbZZ9cuyoxR07LNrand -s 32Sample output (a new value is generated on each run):
pOyNEXu0WtVBRIyDBce329qQRBHj7RtCrand -uuidSample output (a new value is generated on each run):
6c8adb39-adb7-482a-aa3f-1e49570cff33rand -mt 1 100Sample output (a new value is generated on each run):
53rand -mt -seed 42 1 100Sample output (a new value is generated on each run):
43rand -mt -seed 42 -n 3 1 10Sample output (a new value is generated on each run):
3
8
7rand -maxsecure: 9223372036854775807
mt: 2147483647rand 10 1Minimum exceeds maximumrand -n 0Count must be between 1 and 10000rand -b 5000Byte count must be between 1 and 4096rand -s 0String length must be between 1 and 4096rand -seed 42-seed requires -mtrand -b 16 -uuidChoose one output moderand 1 2 3Too many argumentsrand -mysteryUnknown option: -mystery.Current stable release of