try import and export
This commit is contained in:
@@ -116,13 +116,15 @@ class ConfigLoader(QObject):
|
|||||||
@Slot(str, str)
|
@Slot(str, str)
|
||||||
def saveRecoveryKey(self, recovery_file, recovery_password):
|
def saveRecoveryKey(self, recovery_file, recovery_password):
|
||||||
# print(f"In {__file__} file, saveRecoveryKey()")
|
# print(f"In {__file__} file, saveRecoveryKey()")
|
||||||
|
local = False
|
||||||
rp = self.__setRecoveryPassword(recovery_password)
|
rp = self.__setRecoveryPassword(recovery_password)
|
||||||
rf = rp[1] + self.__encrypt_key + rp[0]
|
rf = rp[1] + self.__encrypt_key + rp[0]
|
||||||
rf = Vermasseln().oscarVermasseln(rf)
|
rf = Vermasseln().oscarVermasseln(rf, local)
|
||||||
rec_file = urlparse(recovery_file)
|
rec_file = urlparse(recovery_file)
|
||||||
rec_file = rec_file.path + ".pyqrec"
|
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
rec_file = rec_file [1:]
|
rec_file = rec_file [1:]
|
||||||
|
else:
|
||||||
|
rec_file = rec_file.path + ".pyqrec"
|
||||||
try:
|
try:
|
||||||
with open(rec_file, "w") as f:
|
with open(rec_file, "w") as f:
|
||||||
f.write(rf)
|
f.write(rf)
|
||||||
@@ -133,6 +135,7 @@ class ConfigLoader(QObject):
|
|||||||
@Slot(str, str)
|
@Slot(str, str)
|
||||||
def getRecoveryKey(self, recovery_file, recovery_password):
|
def getRecoveryKey(self, recovery_file, recovery_password):
|
||||||
# print(f"In {__file__} file, getRecoveryKey()")
|
# print(f"In {__file__} file, getRecoveryKey()")
|
||||||
|
local = False
|
||||||
rec_file = urlparse(recovery_file)
|
rec_file = urlparse(recovery_file)
|
||||||
rec_file = rec_file.path
|
rec_file = rec_file.path
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
@@ -140,7 +143,7 @@ class ConfigLoader(QObject):
|
|||||||
try:
|
try:
|
||||||
with open(rec_file, "r") as f:
|
with open(rec_file, "r") as f:
|
||||||
rf = f.read()
|
rf = f.read()
|
||||||
rf = Vermasseln().entschluesseln(rf)
|
rf = Vermasseln().entschluesseln(rf, local)
|
||||||
ek = rf[128:]
|
ek = rf[128:]
|
||||||
ek = ek[:-32]
|
ek = ek[:-32]
|
||||||
password = rf[:128]
|
password = rf[:128]
|
||||||
@@ -171,7 +174,7 @@ class ConfigLoader(QObject):
|
|||||||
rp = self.__setRecoveryPassword(recovery_password, salt)
|
rp = self.__setRecoveryPassword(recovery_password, salt)
|
||||||
return rp[1] == password
|
return rp[1] == password
|
||||||
|
|
||||||
@Slot(str, str)
|
@Slot(str, str) # todo: non local encryption
|
||||||
def importConfig(self, confile, password):
|
def importConfig(self, confile, password):
|
||||||
# print(f"In {__file__} file, importConfig()")
|
# print(f"In {__file__} file, importConfig()")
|
||||||
confile = urlparse(confile)
|
confile = urlparse(confile)
|
||||||
|
|||||||
@@ -18,15 +18,12 @@ class UserDAO:
|
|||||||
print(e.errno)
|
print(e.errno)
|
||||||
user_created = False
|
user_created = False
|
||||||
finally:
|
finally:
|
||||||
# self.__closeConnection()
|
|
||||||
return user_created
|
return user_created
|
||||||
|
|
||||||
def getUser(self, username):
|
def getUser(self, username):
|
||||||
self.__cur.callproc("getUser", (username,))
|
self.__cur.callproc("getUser", (username,))
|
||||||
return self.__cur.fetchone()
|
return self.__cur.fetchone()
|
||||||
|
|
||||||
def __closeConnection(self):
|
|
||||||
self.__cur.close()
|
|
||||||
self.__con.close()
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import string
|
|||||||
|
|
||||||
|
|
||||||
class Vermasseln:
|
class Vermasseln:
|
||||||
def oscarVermasseln(self, data):
|
def oscarVermasseln(self, data, local= True):
|
||||||
b_data = data.encode("utf-8")
|
b_data = data.encode("utf-8")
|
||||||
cipher = self.__vermasslungsKobold()
|
cipher = self.__vermasslungsKobold(local)
|
||||||
|
|
||||||
ciphertext, tag = cipher.encrypt_and_digest(b_data)
|
ciphertext, tag = cipher.encrypt_and_digest(b_data)
|
||||||
decoded_data = [b64encode(x).decode("utf-8") for x in (ciphertext, tag)]
|
decoded_data = [b64encode(x).decode("utf-8") for x in (ciphertext, tag)]
|
||||||
@@ -20,11 +20,11 @@ class Vermasseln:
|
|||||||
|
|
||||||
return storable_data
|
return storable_data
|
||||||
|
|
||||||
def entschluesseln(self, data):
|
def entschluesseln(self, data, local= True):
|
||||||
try:
|
try:
|
||||||
data_list = data.split(".")
|
data_list = data.split(".")
|
||||||
encoded_data = [b64decode(x) for x in data_list]
|
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 = cipher.decrypt_and_verify(encoded_data[0], encoded_data[1])
|
||||||
decrypted_data = decrypted_data.decode("utf-8")
|
decrypted_data = decrypted_data.decode("utf-8")
|
||||||
except (ValueError, IndexError) as e:
|
except (ValueError, IndexError) as e:
|
||||||
@@ -37,12 +37,12 @@ class Vermasseln:
|
|||||||
|
|
||||||
return decrypted_data
|
return decrypted_data
|
||||||
|
|
||||||
def __vermasslungsKobold(self):
|
def __vermasslungsKobold(self, local= True):
|
||||||
key = platform.processor().encode("utf-8")
|
key = platform.processor().encode("utf-8") if local else "(==daniishtverhaftetwegensexy#)"
|
||||||
key = key[0:31]
|
key = key[0:31]
|
||||||
hash_key = SHA256.new(key)
|
hash_key = SHA256.new(key)
|
||||||
hashed = hash_key.digest()
|
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)
|
cipher = AES.new(hashed, AES.MODE_SIV, nonce = nonce)
|
||||||
return cipher
|
return cipher
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user