| Methods |
public
static
|
bytes(int<1, max> $num_bytes): string
Obtains a number of random bytes using the native random_bytes() function.
Obtains a number of random bytes using the native random_bytes() function.
Parameters
| $num_bytes |
the number of bytes to generate
|
Returns
a string containing random bytes
|
#
|
public
|
secret(int<1, max> $num_bytes = 32): string
Obtains a random string of a specified number of bytes of entropy.
Obtains a random string of a specified number of bytes of entropy.
The function calls the bytes() function with the specified
number of bytes, then converts to a string containing only alphanumeric
characters (case sensitive), plus the characters ., _ and -.
The conversion method is based on the Base64 encoding. However, non-standard
characters are used so that users are not confused and attempt to decode
the returned string.
Parameters
| $num_bytes |
the approximate number of bytes of entropy in the
random string
|
Returns
|
#
|
public
|
password(int<1, max> $num_chars = 18): string
Generates a random string that can be used as a password.
Generates a random string that can be used as a password.
The function calls the bytes() function with the specified
number of characters, then converts to a string containing only alphanumeric
characters (case sensitive). The conversion method is a form of Base58
encoding, which strips out confusing characters such as I, l, O and 0.
Parameters
| $num_chars |
the number of characters in the password
|
Returns
|
#
|
public
|
id(): string
Generates a relatively unique identifier which can be used as, among other things,
an OpenID association handle or an OAuth client identifier.
Generates a relatively unique identifier which can be used as, among other things,
an OpenID association handle or an OAuth client identifier.
Note that the identifier returned is not cryptographically secure.
Returns
a relatively unique identifier
|
#
|
public
|
shortCode(int<1, max> $num_digits = 6): string
Generates a short-lived code as a number with a specified number of
digits
Generates a short-lived code as a number with a specified number of
digits
Note that the identifier returned is not cryptographically secure.
Parameters
| $num_digits |
the number of digits
|
Returns
|
#
|