try import and export

This commit is contained in:
2024-12-10 10:06:23 +01:00
parent f9dfcf95bf
commit 28c32dba8a
3 changed files with 15 additions and 15 deletions

View File

@@ -116,13 +116,15 @@ class ConfigLoader(QObject):
@Slot(str, str)
def saveRecoveryKey(self, recovery_file, recovery_password):
# print(f"In {__file__} file, saveRecoveryKey()")
local = False
rp = self.__setRecoveryPassword(recovery_password)
rf = rp[1] + self.__encrypt_key + rp[0]
rf = Vermasseln().oscarVermasseln(rf)
rf = Vermasseln().oscarVermasseln(rf, local)
rec_file = urlparse(recovery_file)
rec_file = rec_file.path + ".pyqrec"
if os.name == "nt":
rec_file = rec_file [1:]
else:
rec_file = rec_file.path + ".pyqrec"
try:
with open(rec_file, "w") as f:
f.write(rf)
@@ -133,6 +135,7 @@ class ConfigLoader(QObject):
@Slot(str, str)
def getRecoveryKey(self, recovery_file, recovery_password):
# print(f"In {__file__} file, getRecoveryKey()")
local = False
rec_file = urlparse(recovery_file)
rec_file = rec_file.path
if os.name == "nt":
@@ -140,7 +143,7 @@ class ConfigLoader(QObject):
try:
with open(rec_file, "r") as f:
rf = f.read()
rf = Vermasseln().entschluesseln(rf)
rf = Vermasseln().entschluesseln(rf, local)
ek = rf[128:]
ek = ek[:-32]
password = rf[:128]
@@ -171,7 +174,7 @@ class ConfigLoader(QObject):
rp = self.__setRecoveryPassword(recovery_password, salt)
return rp[1] == password
@Slot(str, str)
@Slot(str, str) # todo: non local encryption
def importConfig(self, confile, password):
# print(f"In {__file__} file, importConfig()")
confile = urlparse(confile)

View File

@@ -18,15 +18,12 @@ class UserDAO:
print(e.errno)
user_created = False
finally:
# self.__closeConnection()
return user_created
def getUser(self, username):
self.__cur.callproc("getUser", (username,))
return self.__cur.fetchone()
def __closeConnection(self):
self.__cur.close()
self.__con.close()

View File

@@ -10,9 +10,9 @@ import string
class Vermasseln:
def oscarVermasseln(self, data):
def oscarVermasseln(self, data, local= True):
b_data = data.encode("utf-8")
cipher = self.__vermasslungsKobold()
cipher = self.__vermasslungsKobold(local)
ciphertext, tag = cipher.encrypt_and_digest(b_data)
decoded_data = [b64encode(x).decode("utf-8") for x in (ciphertext, tag)]
@@ -20,11 +20,11 @@ class Vermasseln:
return storable_data
def entschluesseln(self, data):
def entschluesseln(self, data, local= True):
try:
data_list = data.split(".")
encoded_data = [b64decode(x) for x in data_list]
cipher = self.__vermasslungsKobold()
cipher = self.__vermasslungsKobold(local)
decrypted_data = cipher.decrypt_and_verify(encoded_data[0], encoded_data[1])
decrypted_data = decrypted_data.decode("utf-8")
except (ValueError, IndexError) as e:
@@ -37,12 +37,12 @@ class Vermasseln:
return decrypted_data
def __vermasslungsKobold(self):
key = platform.processor().encode("utf-8")
def __vermasslungsKobold(self, local= True):
key = platform.processor().encode("utf-8") if local else "(==daniishtverhaftetwegensexy#)"
key = key[0:31]
hash_key = SHA256.new(key)
hashed = hash_key.digest()
nonce = platform.machine().encode("utf-8")
nonce = platform.machine().encode("utf-8") if local else "(==Uskarishtverhaftetwegensexy#)"
cipher = AES.new(hashed, AES.MODE_SIV, nonce = nonce)
return cipher