Skip to content

Commit

Permalink
clipassgen v0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
smartlegionlab committed Jul 11, 2024
1 parent 026fd43 commit fc9eb7a
Show file tree
Hide file tree
Showing 15 changed files with 397 additions and 266 deletions.
61 changes: 31 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# clipassgen <sup>v0.5.1</sup>
# clipassgen <sup>v0.6.0</sup>

***

## Short Description:
___clipassgen___ - Cross-platform console utility for generating
cryptographically strong, recoverable, smart passwords.
___clipassgen___ - Console Smart Passwords Generator. Cross-platform console utility for generating cryptographically strong, recoverable, smart passwords.

***

Expand Down Expand Up @@ -38,21 +37,34 @@ Author and developer: ___A.A. Suvorov___

***

## What's new:

- The code has been completely rewritten and improved.
- Complete renunciation of addictions, even your own. This will allow you to run the application without any problems.
All you need to do is download the source code and run the application. Or install using pip and run.
- Hidden entry of a secret phrase.
- Limit on password length from 10 to 1000.
- Disable the ability to generate smart passwords using command options.
This is done in order to prevent leakage of the secret phrase during generation,
which was specified when generating smart passwords in the console.

> I abandoned the click library, as well as my own dependencies, for the convenience of launching and using the application.
***

## Description:

___clipassgen___ - Cross-platform console utility for generating
cryptographically strong, recoverable, smart passwords.
___clipassgen___ - Console Smart Passwords Generator.

> Smart passwords are not stored anywhere - they are generated on the fly. For a combination - login + secret phrase, or only using a secret phrase,
> you will always receive the same password from 10 to 1000 characters.
> This is as safe as possible. Your passwords are not stored anywhere, they are generated on the fly when requested.
Possibilities:

- Easy installation using pip;
- Generation of complex cryptographic passwords directly from the terminal;
- Generation of common passwords;
- Generation of smart, recoverable passwords linked to a secret phrase;
- Generation of smart, recoverable passwords linked to login and secret phrase;
- Generation from the console using commands and attributes.
- Interactive menu for generator selection with instant response to input.
- Characters are not displayed when entering a secret phrase.
- Generate smart passwords using the combination: login + secret phrase.
- Generate smart passwords using a secret phrase.
- Generate common complex passwords.

Smart Password generator (login + secret phrase):

Expand Down Expand Up @@ -82,23 +94,13 @@ It will be impossible to restore it.
### Install and use:

`pip install clipassgen`
- `clipassgen`

- Show menu:
- `clipassgen`
- `python3 clipassgen.py`
- or use command `menu`

- Generate smart password:
- `clipassgen smart -l [name or login] -s [secret phrase] -n [password length]`
- `python3 clipassgen.py smart -l [name or login] -s [secret] -n [password length]`

- Generate normal password:
- `clipassgen normal -s [secret phrase] -n [password length]`
- `python3 clipassgen.py normal -s [secret phrase] -n [password length]`

- Generate default password:
- `clipassgen base -n [password length]`
- `python3 clipassgen.py base -n [password length]`
or:

- Download.
- Unzip.
- `python app.py`

***

Expand All @@ -124,4 +126,3 @@ It will be impossible to restore it.
Copyright © 2018-2024, A.A. Suvorov
All rights reserved.
--------------------------------------------------------

2 changes: 1 addition & 1 deletion clipassgen.py → app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright © 2018-2024, A.A. Suvorov
# All rights reserved.
# --------------------------------------------------------
# https://github.com/smartlegionlab
# https://github.com/smartlegionlab/
# --------------------------------------------------------
"""Console Smart Passwords Generator."""
from clipassgen.app import cli
Expand Down
10 changes: 6 additions & 4 deletions clipassgen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
# Copyright © 2018-2024, A.A. Suvorov
# All rights reserved.
# --------------------------------------------------------
# https://github.com/smartlegionlab
# https://github.com/smartlegionlab/
# --------------------------------------------------------
"""Cross-platform console utility for generating
cryptographically strong, recoverable, smart passwords."""
__version__ = '0.5.1'
"""
Console Smart Passwords Generator. Cross-platform console utility for
generating cryptographically strong, recoverable, smart passwords.
"""
__version__ = '0.6.0'
58 changes: 6 additions & 52 deletions clipassgen/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,15 @@
# Copyright © 2018-2024, A.A. Suvorov
# All rights reserved.
# --------------------------------------------------------
# https://github.com/smartlegionlab
# https://github.com/smartlegionlab/
# --------------------------------------------------------
import click
"""Console Smart Passwords Generator."""
from clipassgen.app_manager import AppManager

from clipassgen.config import Config
from clipassgen.manager import CliMan


@Config.click_group
@click.version_option(f'{CliMan.name} v{CliMan.version}')
@click.pass_context
def cli(ctx):
CliMan.show_head()
if ctx.invoked_subcommand is None:
CliMan.commander.menu()


@cli.command('menu')
def menu():
return CliMan.commander.menu()


@cli.command('smart')
@Config.name_option
@Config.secret_option
@Config.length_option
def smart(login, secret, num):
return CliMan.commander.smart(
login,
secret,
num,
)


@cli.command('normal')
@Config.length_option
@Config.secret_option
def normal(secret, num):
return CliMan.commander.normal(
secret=secret,
length=num,
)


@cli.command('base')
@Config.length_option
def default(num):
return CliMan.commander.base(
length=num,
)


@cli.result_callback()
def process_result(result):
CliMan.show_footer()
def cli():
app_manager = AppManager()
app_manager.main_menu()


if __name__ == '__main__':
Expand Down
107 changes: 107 additions & 0 deletions clipassgen/app_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# --------------------------------------------------------
# Licensed under the terms of the BSD 3-Clause License
# (see LICENSE for details).
# Copyright © 2018-2024, A.A. Suvorov
# All rights reserved.
# --------------------------------------------------------
# https://github.com/smartlegionlab/
# --------------------------------------------------------
import getpass
import sys

from clipassgen.config import Config
from clipassgen.smart_pass_gen import SmartPasswordMaster
from clipassgen.smart_printer import SmartPrinter


class AppManager:

def __init__(self):
self.config = Config()
self.smart_printer = SmartPrinter()
self.smart_pass_gen = SmartPasswordMaster()

def main_menu(self):
self.smart_printer.show_head(text=self.config.name)
while True:
self.smart_printer.print_center('Main Menu:')
print('1. Smart password generator (with login).')
print('2. Smart password generator.')
print('3. Base password generator.')
print('0. Exit.')
choice = input('Enter your choice: ')
if choice == '1':
self.generate_smart_password_with_login()
elif choice == '2':
self.generate_smart_password()
elif choice == '3':
self.generate_base_password()
elif choice == '0':
self.exit_app()
else:
self.smart_printer.print_framed('Error! Invalid choice')

@staticmethod
def _get_login():
while True:
login = input('Enter your login: ')
if not login:
print('Invalid login')
return login

@staticmethod
def _get_secret():
while True:
secret = getpass.getpass("Enter secret phrase (hidden): ")
if not secret:
print('No secret phrase entered!')
continue
return secret

@staticmethod
def _get_length():
while True:
length = input('Enter length: ')
try:
length = int(length)
if not length or (length < 10 or length > 1000):
raise ValueError
except ValueError:
print('Invalid length! (10-1000)')
continue
return length

@staticmethod
def _continue():
input('Press enter to continue... ')

def generate_smart_password_with_login(self):
self.smart_printer.print_center(text='Smart Password (with login)')
login = self._get_login()
secret = self._get_secret()
length = self._get_length()
password = self.smart_pass_gen.get_smart_password(login, secret, length)
self.show_password(password)

def generate_smart_password(self):
self.smart_printer.print_center(text='Smart Password')
secret = self._get_secret()
length = self._get_length()
password = self.smart_pass_gen.get_smart_password(secret=secret, length=length)
self.show_password(password)

def generate_base_password(self):
self.smart_printer.print_center(text='Base Password')
length = self._get_length()
password = self.smart_pass_gen.get_password(length=length)
self.show_password(password)

def show_password(self, password):
print(f'\n{password}\n')
self._continue()

def exit_app(self):
self.smart_printer.print_center(text=self.config.url)
self.smart_printer.print_center(text=self.config.copyright_)
self.smart_printer.print_center(char='*')
sys.exit(0)
Loading

0 comments on commit fc9eb7a

Please sign in to comment.