Skip to main content

Random data generators. Allows you to generate random strings of a given length from letters, numbers and symbols, as well as randomize text. Helps generate passwords, service codes (for example, for sending via SMS), hashes and much more. Generates smart, recoverable passwords.

Project description

smartrandom v0.3.1


Random Data Generators:

Random data generators. Allows you to generate random strings of a given length from letters, numbers and symbols, as well as randomize text. Helps generate passwords, service codes (for example, for sending via SMS), hashes and much more. Generates smart, recoverable passwords.


PyPI Downloads GitHub release (latest by date) PyPI - Downloads GitHub top language PyPI GitHub PyPI - Format


Author and developer: A.A. Suvorov.


What is news:

smartrandom 0.3.1 - new improved version of the library.

  • Added a regular password generator.
  • Added a smart password generator.
  • Improved tests

Help:

pip install smartrandom

from smartrandom import RandomDataGenerator


secret_code = RandomDataGenerator.generate_secret_code(length=6) # 'zREkjF'
number_secret_code = RandomDataGenerator.generate_random_numbers(length=6) # '986741'
symbols = RandomDataGenerator.generate_random_symbols(length=10) # '&&!@@&@!_!'
hash_ = RandomDataGenerator.generate_hash(text='text') # '1798b0ae66b1ca6f3b88e00f9d17ce1470549e97687a1c97e26110bb8853ad41797e83831efe7eedbd29042a9a8991fd1adb4f7680946d57eed99b8b6e5502c4'
urandom_string = RandomDataGenerator.generate_random_hex_string(size=32) # '7b1dd304b42e79d9e26bfb9f839abf8d001fed2039bcc3c5bfd14c0b05cfcab2'
urandom_bytes = RandomDataGenerator.generate_random_bytes(size=32) # b'f_@\x1bnP\xb4\xa8\xb7$a\xbf\x13\r#\x96\xe5\x07D\xa1N\xf5\xe9\x9a\x95\x91\xe4\xd0\x8fR"\''
randomized_text = RandomDataGenerator.randomize_text('{Salute|Hello|Good morning} {comrade|buddy|dear friend}!') # Good morning buddy!
password = RandomDataGenerator.generate_password(length=15) # 'b$L^#7rfIUzgY!2'
base_password = RandomDataGenerator.generate_base_password(length=15) # '$yE$JL8heeJQv5X'
smart_password1 = RandomDataGenerator.generate_smart_password(seed='test', length=15) # 'GEyfYrC%VJU!RSY'
smart_password2 = RandomDataGenerator.generate_smart_password(seed='test2', length=15) # '2PhIQt8pIke9c@m'
smart_password3 = RandomDataGenerator.generate_smart_password(seed='test', length=15) # 'GEyfYrC%VJU!RSY'
smart_password4 = RandomDataGenerator.generate_smart_password(seed='test2', length=15) # '2PhIQt8pIke9c@m'

Text randomizer:

"Text randomization" or "variable text". It is used to create different variations of the same message.

You are using special syntax. Example: '{Salute|Hello|Good morning} {comrade|buddy|dear friend}!'

This syntax allows you to create variable messages by using curly braces and vertical bars to indicate alternatives.

Basic elements of syntax:

  1. Curly braces {}: Used to group text options. Anything inside the curly braces will be randomly selected when generating the text.
  2. Vertical bar |: Used to separate different text options within curly braces. Each option will be treated as a separate choice.

Example of use:

  • Syntax: '{Salute|Hello|Good morning} {comrade|buddy|dear friend}!'

  • Possible results:

    • Salute comrade!
    • Salute buddy!
    • Salute dear friend!
    • Hello comrade!
    • Hello buddy!
    • Hello dear friend!
    • Good morning comrade!
    • Good morning buddy!
    • Good morning dear friend!
  • How to use:

    1. Create your text: Identify which parts of your message can vary and place them in curly braces.
    2. Add options: Separate alternatives with a vertical bar.
    3. Text Generation: Use RandomStringMaster() to generate a random message.
  • Notes:

    • Make sure all options inside the curly braces make sense and fit the context.
    • You can use multiple randomization groups in a single message to create more complex variations.

Example of text randomization:

from smartrandom import TextRandomizer

text = '{Salute|Hello|Good morning} {comrade|buddy|dear friend}!'
randomized_text = TextRandomizer.randomize(text)
print(randomized_text)  # Good morning buddy!

Test coverage:

Run tests:

  • pip install pytest
  • pytest -v

Test coverage 100%

  • pip install pytest-coverage
  • pytest --cov

commandpack image

Report html:

  • pytest --cov --cov-report=html


Disclaimer of liability:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Copyright:

--------------------------------------------------------
Licensed under the terms of the BSD 3-Clause License
(see LICENSE for details).
Copyright © 2018-2024, A.A. Suvorov
All rights reserved.
--------------------------------------------------------

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smartrandom-0.3.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smartrandom-0.3.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file smartrandom-0.3.1.tar.gz.

File metadata

  • Download URL: smartrandom-0.3.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for smartrandom-0.3.1.tar.gz
Algorithm Hash digest
SHA256 683d4140649e76bf2df0cec33562207d2c1ccb7627c776e9302fe33a15118b8c
MD5 7c37bc6a0779ae448b371c825949fc27
BLAKE2b-256 71ac4cd904629f1546f4cae428f03de80e4f37ff097dafc2aa02386454539781

See more details on using hashes here.

File details

Details for the file smartrandom-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: smartrandom-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for smartrandom-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 07c423b32cdf0901bb136b8153a16f0f8270498304d4804bf33ca1918439a991
MD5 554189016fbb0192aaa34ff6c181e42b
BLAKE2b-256 27b0a00affa546d6976d1b62a219a8fb73f1f297f0cdb8e6d8caf765230a6f87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page