db and settings encryption

This commit is contained in:
ingvar1995 2016-05-15 23:02:05 +03:00
parent 0fa7ca7b5c
commit 21d5eed719
3 changed files with 28 additions and 0 deletions

View file

@ -18,6 +18,9 @@ class Settings(Singleton, dict):
if os.path.isfile(self.path):
with open(self.path) as fl:
data = fl.read()
inst = LibToxEncryptSave.get_instance()
if inst.has_password():
data = inst.pass_decrypt(data)
try:
info = json.loads(data)
except Exception as ex:
@ -97,6 +100,9 @@ class Settings(Singleton, dict):
def save(self):
text = json.dumps(self)
inst = LibToxEncryptSave.get_instance()
if inst.has_password():
text = inst.pass_encrypt(text)
with open(self.path, 'w') as fl:
fl.write(text)