Introduction
This package provides a simple way how to generate timestamped random strings with minimal length of 8 characters. The first 6 characters are the timestamp in seconds and the remaining set of characters (required length - 6) are randomly generated.
The random string is generated using the following set of characters: abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789 as you can see the characters l and I are not included to avoid confusion with 1 and 0.
The key advantage of this package is the ability to generate completely unique and not easily predictible strings with the performace:
- 57 strings per 1 seconds for a length of 7 characters
- 3,249 strings per 1 seconds for a length of 8 characters
- 185,193 strings per 1 seconds for a length of 9 characters
Usage
# import the randomizer
from surquest.utils.randomizer import Randomizer
# Generate a timestamped random string with a length of 8 characters
random_string = Randomizer.generate_timestamped_random_string(
string_length=8
) # returns something like `gechEuKq`
Installation
The package is available on PyPI and can be installed using pip:
pip install surquest-utils-random-string-generator
Additional information
You are also able to submit your own set of characters to be used for the random string generation.
import string
from surquest.utils.randomizer import Randomizer
# Generate a timestamped random string with a length of 8 characters
randomizer = Randomizer(
string_length=8,
characters=string.ascii_letters + string.digits
)
random_string = randomizer.generate_timestamped_random_string(10)
The Randomizer class can be also used for conversion of integers to strings based on given set of characters.
from surquest.utils.randomizer import Randomizer
randomizer = Randomizer()
# input number
number = 1234567890
# convert number to string
random_string = randomizer.convert_integer_to_charset(number)
# convert string back to number
number = randomizer.convert_charset_to_integer(random_string)
Local development
You are more than welcome to contribute to this project. To make your start easier we have prepared a docker image with all the necessary tools to run it as interpreter for Pycharm or to run tests.
Build docker image
# powershell syntax (windows)
docker build `
--tag surquest/utils/randomizer `
--file package.base.dockerfile `
--target test .
Run tests
# powershell syntax (windows)
docker run --rm -it `
-v "${pwd}:/opt/project" `
-w "/opt/project/test" `
surquest/utils/randomizer pytest
Metadata
Release files for surquest-utils-random-string-generator 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| surquest_utils_random_string_generator-0.0.1.tar.gz | 8.3 kB | Without provenance | Details for surquest_utils_random_string_generator-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| surquest_utils_random_string_generator-0.0.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for surquest_utils_random_string_generator-0.0.1-py2.py3-none-any.whl |
Total release size: 14.0 kB
Release files / surquest_utils_random_string_generator-0.0.1.tar.gz
| Download URL | surquest_utils_random_string_generator-0.0.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf2c949c6a1f2c4eafcd2c4a983f0e4847c47f65732a6bb84cd07df62a3e30eb
|
|
BLAKE2b-256 checksum How to use checksums |
72fb4b7ec13222651ed9faa3b529f47b72a87227dd2fa6fd528933d4b4a1e564
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|
Release files / surquest_utils_random_string_generator-0.0.1-py2.py3-none-any.whl
| Download URL | surquest_utils_random_string_generator-0.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
7634bd1f13d6063bcc51dbf6ac47b9ccce259a30ba47d2672acdbf43952c675b
|
|
BLAKE2b-256 checksum How to use checksums |
099f188665de2cce76794b748fb9631559a38b8460595707788ea2c6233224eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|
Security for surquest-utils-random-string-generator 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.