Download the PHP package katmore/intl-rand-string without Composer
On this page you can find all versions of the php package katmore/intl-rand-string. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download katmore/intl-rand-string
More information about katmore/intl-rand-string
Files in katmore/intl-rand-string
Package intl-rand-string
Short Description generate internationalized random alpha-numeric strings
License MIT GPL-3.0+
Homepage https://github.com/katmore/intl-rand-string
Informations about the package intl-rand-string
IntlRandString
generate internationalized random alpha-numeric strings
- Usage in a PHP Project
- Standalone Utility
- Development
About
The IntlRandString package facilitates generating random strings in multiple internationalized character sets. A typical use-case is generating random passwords in a targeted "language", i.e. using characters familiar to a language rather than simply using only english latin characters, as is typical. For similar reasons, it could also prove ideal in other use-cases, such as: password reset validation codes, coupon or promotional codes, etc.
Usage in a PHP Project
use composer to add IntlRandString to your PHP project:
A random string can be generated with the following character sets:
- Cyrillic
- English
- German
- Italian
- Spanish
Cyrillic Charset
Example, using the Cyrillic Charset to generate a random string:
The above example should output a random string that includes only cyrillic characters and latin digits, such as follows:
English Charset
Example, using the English Charset to generate a random string:
The above example should output a random string that includes only latin characters and latin digits as used in English, such as follows:
German Charset
Example, using the German Charset to generate a random string:
The above example should output a random string that includes only latin characters and latin digits as used in German, such as follows:
Italian Charset
Example, using the Italian Charset to generate a random string:
The above example should output a random string that includes only latin characters and latin digits as used in Italian, such as follows:
Spanish Charset
Example, using the Spanish Charset to generate a random string:
The above example should output a random string that includes only latin characters and latin digits as used in Spanish, such as follows:
Development
The following utility scripts facilitate development of character sets:
- make-charset.php
- make-all-charsets.sh
unit tests
The unit tests specified by phpunit.xml
check the basic sanity and entropy of generated random strings for each character set.
make-charset.php dev utility
The bin/devel/make-charset.php
command-line developer utility script creates a character set class defintion PHP source file in the src/IntlRandString/Charset
directory. After creating a character set, perform all unit tests to ensure conformity.
Specifying the --help
option will display usage details.
make-all-charsets.sh dev utility
The bin/devel/make-all-charsets.sh
command-line developer utility script contains the Unicode start and end points for all character set defintion source files.
The Unicode character ranges for the Charsets are ultimately defined in perform all unit tests to ensure conformity.
For example, the make-all-charsets.sh as follows:
rand-string utility
A standalone utility is provided by the bin/rand-string.php
script. Details regarding the usage of this utility and instructions for an optional global installation are included in this section.
rand-string standalone installation
These installation instructions rely on the make-phar.sh
installer script. See the make-phar.sh utility section for more in-depth details and troubleshooting.
Installation instructions:
-
Download intl-rand-string project using git (or similar), and enter the project directory.
- Use the
bin/install/make-phar.sh
utility with the--install
flag to create and install the phar package on your system.
rand-string utility examples
The rand-string
(or bin/rand-string.php
) command line utility generates random strings.
Example #1, using default charset and length.
-
the following command
- should produce output similar to the following
The first positional argument specifies the length of the random string.
Example #2, using default charset and specifying length:
-
the following command
- should produce output similar to the following
A charset may be specified for one-time use with the --charset=<CHARSET-NAME>
flag.
Example #3, using cyrillic
charset:
-
the following command
- should produce output similar to the following
The English
charset is the global default, though this may be changed (see usage).
Example #3, setting the german
as default:
-
the following command
-
should produce output similar to the following
-
subsequent executions should produce random strings using the
german
charset, the following command - should produce output similar to the following
Any Charset available in IntlRandString\Charset
may be used.
Example #4, getting a list of available charsets:
-
the following command
-
should produce output similar to the following
-
and thus, the following command
- should produce output similar to the following
rand-string utility usage
make-phar.sh utility
The bin/install/make-phar.sh
utility creates a standalone rand-string.phar
phar package file using bin/rand-string.php
as the entrypoint. Optionally, it will copy the phar package file to an installation path.
Prerequisites
- composer
- php command line binary
Usage
Legal
Copyright
IntlRandString - https://github.com/katmore/intl-rand-string
Copyright (c) 2012-2018 Doug Bird. All Rights Reserved.
License
IntlRandString is copyrighted free software. You may redistribute and modify it under either the terms and conditions of the "The MIT License (MIT)"; or the terms and conditions of the "GPL v3 License". See LICENSE and GPLv3.