Renamed cryptogra[hy folder into encryption to not overshadow cryptography module

This commit is contained in:
StNicolay 2022-11-30 20:24:46 +03:00
parent 138ec55ae5
commit b42cbb57a4
5 changed files with 16 additions and 14 deletions

View File

@ -6,7 +6,7 @@ from . import (
account_checks, account_checks,
account_parsing, account_parsing,
bot, bot,
cryptography, encryption,
database, database,
generate_password, generate_password,
) )
@ -15,7 +15,7 @@ __all__ = [
"account_checks", "account_checks",
"account_parsing", "account_parsing",
"bot", "bot",
"cryptography", "encryption",
"database", "database",
"generate_password", "generate_password",
] ]

View File

@ -5,7 +5,7 @@ import time
import telebot import telebot
from sqlalchemy.future import Engine from sqlalchemy.future import Engine
from .. import cryptography, database, generate_password from .. import encryption, database, generate_password
from ..account_checks import ( from ..account_checks import (
check_account, check_account,
check_account_name, check_account_name,
@ -110,7 +110,7 @@ def _set_master_pass2(
if text == "/cancel": if text == "/cancel":
return _send_tmp_message(bot, mes.chat.id, "Успешная отмена") 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, text,
) )
database.add.add_master_pass( database.add.add_master_pass(
@ -150,7 +150,7 @@ def _reset_master_pass2(
if text == "/cancel": if text == "/cancel":
return _send_tmp_message(bot, mes.chat.id, "Успешная отмена") 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.delete.purge_accounts(engine, mes.from_user.id)
database.change.change_master_pass(engine, mes.from_user.id, salt, hash_) database.change.change_master_pass(engine, mes.from_user.id, salt, hash_)
_send_tmp_message( _send_tmp_message(
@ -263,7 +263,7 @@ def _add_account5(
return _send_tmp_message(bot, mes.chat.id, "Успешная отмена") return _send_tmp_message(bot, mes.chat.id, "Успешная отмена")
salt, hash_ = database.get.get_master_pass(engine, mes.from_user.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( return _send_tmp_message(
bot, bot,
mes.chat.id, mes.chat.id,
@ -272,7 +272,7 @@ def _add_account5(
name, login, passwd = data["name"], data["login"], data["passwd"] 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, login,
passwd, passwd,
text, text,
@ -340,7 +340,7 @@ def _get_account3(
mes.from_user.id, mes.from_user.id,
) )
if not cryptography.master_pass.check_master_pass( if not encryption.master_pass.check_master_pass(
text, text,
hash_pass, hash_pass,
master_salt, master_salt,
@ -350,7 +350,7 @@ def _get_account3(
salt, enc_login, enc_pass = database.get.get_account_info( salt, enc_login, enc_pass = database.get.get_account_info(
engine, mes.from_user.id, name engine, mes.from_user.id, name
) )
login, passwd = cryptography.other_accounts.decrypt( login, passwd = encryption.other_accounts.decrypt(
enc_login, enc_login,
enc_pass, enc_pass,
text, text,
@ -454,7 +454,7 @@ def _export2(
engine, engine,
mes.from_user.id, mes.from_user.id,
) )
if not cryptography.master_pass.check_master_pass( if not encryption.master_pass.check_master_pass(
text, text,
hash_pass, hash_pass,
master_salt, master_salt,
@ -462,7 +462,7 @@ def _export2(
return _send_tmp_message(bot, mes.chat.id, "Не подходит мастер пароль") return _send_tmp_message(bot, mes.chat.id, "Не подходит мастер пароль")
accounts = database.get.get_all_accounts(engine, mes.from_user.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) json_io = accounts_to_json(accounts)
bot_mes = bot.send_document(mes.chat.id, json_io) bot_mes = bot.send_document(mes.chat.id, json_io)
@ -544,7 +544,7 @@ def _import3(
engine, engine,
mes.from_user.id, mes.from_user.id,
) )
if not cryptography.master_pass.check_master_pass( if not encryption.master_pass.check_master_pass(
text, text,
hash_pass, hash_pass,
master_salt, master_salt,
@ -559,8 +559,10 @@ def _import3(
if not check_account(name, login, passwd): if not check_account(name, login, passwd):
failed.append(name) failed.append(name)
continue continue
enc_login, enc_passwd, salt = cryptography.other_accounts.encrypt( enc_login, enc_passwd, salt = encryption.other_accounts.encrypt(
login, passwd, text login,
passwd,
text,
) )
result = database.add.add_account( result = database.add.add_account(
engine, mes.from_user.id, name, salt, enc_login, enc_passwd engine, mes.from_user.id, name, salt, enc_login, enc_passwd