From e76354a919847a10817e0e2fce5942d3b3fa2446 Mon Sep 17 00:00:00 2001 From: kromskii2 Date: Mon, 19 Feb 2024 14:31:18 +0700 Subject: [PATCH] =?UTF-8?q?Initial=20commit=20password=5Fgenerator.py=20?= =?UTF-8?q?=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D1=91=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 2 + .gitignore | 152 ++++++++++++++++++++++++++++++++++++++++++ LICENSE | 21 ++++++ README.md | 44 ++++++++++++ password_generator.py | 37 ++++++++++ 5 files changed, 256 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 password_generator.py diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d9005f2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,152 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..44c36a5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 kromskii2 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2ef6c28 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# Генератор случайных паролей + +Этот скрипт на Python предоставляет удобный способ генерации случайных паролей с настройками через консоль. + +## Особенности + +- Генерация паролей различной длины. +- Пользователь может выбрать, какие типы символов использовать: строчные буквы, прописные буквы, цифры и/или рандомизированные символы. +- Простой интерфейс через консоль. +- Поддержка кириллицы в комментариях и документации. + +## Использование + +1. Установите Python, если его еще нет на вашем компьютере. Можно скачать [здесь](https://www.python.org/downloads/). +2. Скачайте файл `password_generator.py`. +3. Откройте терминал или командную строку и перейдите в каталог с файлом `password_generator.py`. +4. Запустите скрипт, выполнив следующую команду: + ```bash + python password_generator.py + ``` +5. Следуйте инструкциям в консоли, чтобы настроить параметры генерации пароля. + +## Пример + +```bash +$ python password_generator.py +Введите длину пароля: 12 +Использовать строчные буквы? (да/нет): да +Использовать прописные буквы? (да/нет): да +Использовать цифры? (да/нет): да +Использовать рандомизированные символы? (да/нет): да +Сгенерированный пароль: 5T#q1W9D@J2r +Замечания +Не забудьте сохранить сгенерированный пароль в безопасном месте после использования. +Помните, что безопасность пароля зависит не только от его длины, но и от разнообразия использованных символов. +Автор +Автор: Kromskii2 + +Если у вас возникли проблемы или у вас есть предложения по улучшению скрипта, пожалуйста, создайте issue на GitHub. + +Лицензия +Этот проект лицензируется под MIT License. + + diff --git a/password_generator.py b/password_generator.py new file mode 100644 index 0000000..db7e38e --- /dev/null +++ b/password_generator.py @@ -0,0 +1,37 @@ +import random +import string + + +def generate_password(length, use_lowercase, use_uppercase, use_digits, use_symbols): + characters = '' + if use_lowercase: + characters += string.ascii_lowercase + if use_uppercase: + characters += string.ascii_uppercase + if use_digits: + characters += string.digits + if use_symbols: + characters += '!#$' + + if not characters: + print("Ошибка: Не выбраны типы символов для использования.") + return None + + password = ''.join(random.choice(characters) for _ in range(length)) + return password + + +def main(): + length = int(input("Введите длину пароля: ")) + use_lowercase = input("Использовать строчные буквы? (да/нет): ").lower() == 'да' + use_uppercase = input("Использовать прописные буквы? (да/нет): ").lower() == 'да' + use_digits = input("Использовать цифры? (да/нет): ").lower() == 'да' + use_symbols = input("Использовать рандомизированные символы? (да/нет): ").lower() == 'да' + + password = generate_password(length, use_lowercase, use_uppercase, use_digits, use_symbols) + if password: + print("Сгенерированный пароль:", password) + + +if __name__ == "__main__": + main()