-
Notifications
You must be signed in to change notification settings - Fork 0
Usage
Function | Functionality |
---|---|
string | Generates a random string. |
integer | Generates a random integer. |
password | Generates an alphanumeric password with at least one lowercase character, at least one uppercase character, and at least three digits. |
bytes | Generates a random byte string. |
hex | Generates a random byte string. |
urlsafe | Generates a random byte string. |
database | Generates a random ID using the string or integer functions, then it checks it's uniqueness against database. |
The string function generates a random string value. Possible arguments are:
Argument | Default | Type | Functionality |
---|---|---|---|
length | 6 | int | Length in characters |
prefix | None | str | Prefix to add before the output string. The prefix will not affect the character length of the output. So the total length will be the length of the generated ID plus the length of the prefix. |
ignore_max_length | False | bool | Normally the program will fail when the length is set to a value higher than 1000. This can be omitted by setting "ignore_max_length" to True |
type | all | str | The function can output letters and numbers . |
uppercase_only | False | bool | Output only uppercase letters. Numbers will stay the same. |
lowercase_only | False | bool | Output only lowercase letters. Numbers will stay the same. |
The integer function generates a random integer value. Possible arguments are:
Argument | Default | Type | Functionality |
---|---|---|---|
length | 6 | int | Length in characters |
prefix | None | int | Prefix to add before the output string. The prefix will not affect the character length of the output. So the total length will be the length of the generated ID plus the length of the prefix. |
ignore_max_length | False | bool | Normally the program will fail when the length is set to a value higher than 1000. This can be omitted by setting "ignore_max_length" to True |
The password function generates a random alphanumeric password that is at least 3 characters long and with at least one lowercase character and one upppercase character. Possible arguments are:
Argument | Default | Type | Functionality |
---|---|---|---|
length | 10 | int | Length in characters |
ignore_max_length | False | bool | Normally the program will fail when the length is set to a value higher than 1000. This can be omitted by setting "ignore_max_length" to True |
The bytes function returns a random byte string containing 32 bytes. Possible arguments are:
Argument | Default | Type | Functionality |
---|---|---|---|
length | 32 | int | Length in bytes |
ignore_max_length | False | bool | Normally the program will fail when the length is set to a value higher than 1000. This can be omitted by setting "ignore_max_length" to True |
The hex function returns a random text string in hexadecimal. The string has 32 random bytes, each byte converted to two hex digits. Possible arguments are:
Argument | Default | Type | Functionality |
---|---|---|---|
length | 32 | int | Length in bytes |
ignore_max_length | False | bool | Normally the program will fail when the length is set to a value higher than 1000. This can be omitted by setting "ignore_max_length" to True |
The urlsafe function returns a random URL safe text string containing 32 bytes. The text is Base64 encoded, so on average each byte results in approximately 1.3 characters. Possible arguments are:
Argument | Default | Type | Functionality |
---|---|---|---|
length | 32 | int | Length in bytes |
ignore_max_length | False | bool | Normally the program will fail when the length is set to a value higher than 1000. This can be omitted by setting "ignore_max_length" to True |
Two string arguments padding
and encoded
can be passed into the urlsafe function.
padding
will append padding (=
) to the generated byte string. This is useful for encryption.
encoded
will encode the output to bytes.
The database function wraps around either the string or the integer functions. It will read a SQL database cursor and check if the ID it generates already exists in the database table. If it exists, it will try again until it doesn't.
Possible arguments are:
Argument | Default | Type | Functionality |
---|---|---|---|
cursor | undefined | dictionary | SQL database cursor object |
The cursor object is a dictionary structured like such:
cursor = {
"cursor": cursor, ## Currently only tested with MYSQL
"table": "table_name",
"column": "column_name"
}