From b42cbb57a4d22c7ab7784bd0e4381b0496d3e835 Mon Sep 17 00:00:00 2001 From: StNicolay Date: Wed, 30 Nov 2022 20:24:46 +0300 Subject: [PATCH] Renamed cryptogra[hy folder into encryption to not overshadow cryptography module --- src/__init__.py | 4 +-- src/bot/handlers.py | 26 ++++++++++--------- src/{cryptography => encryption}/__init__.py | 0 .../master_pass.py | 0 .../other_accounts.py | 0 5 files changed, 16 insertions(+), 14 deletions(-) rename src/{cryptography => encryption}/__init__.py (100%) rename src/{cryptography => encryption}/master_pass.py (100%) rename src/{cryptography => encryption}/other_accounts.py (100%) diff --git a/src/__init__.py b/src/__init__.py index b7435f5..50e3dae 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -6,7 +6,7 @@ from . import ( account_checks, account_parsing, bot, - cryptography, + encryption, database, generate_password, ) @@ -15,7 +15,7 @@ __all__ = [ "account_checks", "account_parsing", "bot", - "cryptography", + "encryption", "database", "generate_password", ] diff --git a/src/bot/handlers.py b/src/bot/handlers.py index 6df8254..b43d9af 100644 --- a/src/bot/handlers.py +++ b/src/bot/handlers.py @@ -5,7 +5,7 @@ import time import telebot from sqlalchemy.future import Engine -from .. import cryptography, database, generate_password +from .. import encryption, database, generate_password from ..account_checks import ( check_account, check_account_name, @@ -110,7 +110,7 @@ def _set_master_pass2( if text == "/cancel": return _send_tmp_message(bot, mes.chat.id, "Успешная отмена") - password_hash, master_salt = cryptography.master_pass.encrypt_master_pass( + password_hash, master_salt = encryption.master_pass.encrypt_master_pass( text, ) database.add.add_master_pass( @@ -150,7 +150,7 @@ def _reset_master_pass2( if text == "/cancel": return _send_tmp_message(bot, mes.chat.id, "Успешная отмена") - hash_, salt = cryptography.master_pass.encrypt_master_pass(text) + hash_, salt = encryption.master_pass.encrypt_master_pass(text) database.delete.purge_accounts(engine, mes.from_user.id) database.change.change_master_pass(engine, mes.from_user.id, salt, hash_) _send_tmp_message( @@ -263,7 +263,7 @@ def _add_account5( return _send_tmp_message(bot, mes.chat.id, "Успешная отмена") salt, hash_ = database.get.get_master_pass(engine, mes.from_user.id) - if not cryptography.master_pass.check_master_pass(text, hash_, salt): + if not encryption.master_pass.check_master_pass(text, hash_, salt): return _send_tmp_message( bot, mes.chat.id, @@ -272,7 +272,7 @@ def _add_account5( name, login, passwd = data["name"], data["login"], data["passwd"] - enc_login, enc_pass, salt = cryptography.other_accounts.encrypt( + enc_login, enc_pass, salt = encryption.other_accounts.encrypt( login, passwd, text, @@ -340,7 +340,7 @@ def _get_account3( mes.from_user.id, ) - if not cryptography.master_pass.check_master_pass( + if not encryption.master_pass.check_master_pass( text, hash_pass, master_salt, @@ -350,7 +350,7 @@ def _get_account3( salt, enc_login, enc_pass = database.get.get_account_info( engine, mes.from_user.id, name ) - login, passwd = cryptography.other_accounts.decrypt( + login, passwd = encryption.other_accounts.decrypt( enc_login, enc_pass, text, @@ -454,7 +454,7 @@ def _export2( engine, mes.from_user.id, ) - if not cryptography.master_pass.check_master_pass( + if not encryption.master_pass.check_master_pass( text, hash_pass, master_salt, @@ -462,7 +462,7 @@ def _export2( return _send_tmp_message(bot, mes.chat.id, "Не подходит мастер пароль") accounts = database.get.get_all_accounts(engine, mes.from_user.id) - accounts = cryptography.other_accounts.decrypt_multiple(accounts, text) + accounts = encryption.other_accounts.decrypt_multiple(accounts, text) json_io = accounts_to_json(accounts) bot_mes = bot.send_document(mes.chat.id, json_io) @@ -544,7 +544,7 @@ def _import3( engine, mes.from_user.id, ) - if not cryptography.master_pass.check_master_pass( + if not encryption.master_pass.check_master_pass( text, hash_pass, master_salt, @@ -559,8 +559,10 @@ def _import3( if not check_account(name, login, passwd): failed.append(name) continue - enc_login, enc_passwd, salt = cryptography.other_accounts.encrypt( - login, passwd, text + enc_login, enc_passwd, salt = encryption.other_accounts.encrypt( + login, + passwd, + text, ) result = database.add.add_account( engine, mes.from_user.id, name, salt, enc_login, enc_passwd diff --git a/src/cryptography/__init__.py b/src/encryption/__init__.py similarity index 100% rename from src/cryptography/__init__.py rename to src/encryption/__init__.py diff --git a/src/cryptography/master_pass.py b/src/encryption/master_pass.py similarity index 100% rename from src/cryptography/master_pass.py rename to src/encryption/master_pass.py diff --git a/src/cryptography/other_accounts.py b/src/encryption/other_accounts.py similarity index 100% rename from src/cryptography/other_accounts.py rename to src/encryption/other_accounts.py