-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
75 lines (67 loc) · 2.57 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import languages
language = languages.loadLanguage()
checkUpdates = None
n = 18 # affects time and memory (is used as 2**n)
r = 32 # affects memory and with n also time
p = 1 # affects time
pwdLenBytes = 8 # length of the argument which holds the length of the password section in bytes
saltLenBytes = 16
extension = ".enc"
# has to be in the format "vx.y.z" where x and y are chars (0-255)
# changing the version number will lead to unexpected behavior and could lead to corrupted files
# especially when the goal is to fake an update to be entitled to decrypt some newer version files
version = "v0.1.5"
def isFileCompatible(majorVersion, minorVersion) -> bool:
majorVersion = int(majorVersion)
minorVersion = int(minorVersion)
programMajor = int(version[1:].split(".")[0])
programMinor = int(version.split(".")[1])
if majorVersion > programMajor:
return False
if majorVersion == programMajor and minorVersion > programMinor:
return False
return True
def isVersionNewer(newVersion : str) -> bool:
newVersionMajor = int(newVersion[1:].split(".")[0])
programMajor = int(version[1:].split(".")[0])
if newVersionMajor > programMajor:
return True
elif newVersionMajor == programMajor:
newVersionMinor = int(newVersion.split(".")[1])
programMinor = int(version.split(".")[1])
if newVersionMinor > programMinor:
return True
elif newVersionMinor == programMinor:
if len(newVersion.split(".")) == 3:
newVersionPatch = int(newVersion.split(".")[2])
else:
newVersionPatch = 0
if len(version.split(".")) == 3:
programPatch = int(version.split(".")[2])
else:
programPatch = 0
return newVersionPatch > programPatch
return False
def setLanguage(lang):
global language
open("language.txt", "w").write(lang)
language = languages.loadLanguage()
def setUpdateChecker(shouldCheck):
global checkUpdates
open("updateCheck.txt", "w").write(str(shouldCheck))
checkUpdates = shouldCheck
def loadUpdateChecker():
global checkUpdates
try:
content = open("updateCheck.txt", "r").read()
if content == "True":
checkUpdates = True
elif content == "False":
checkUpdates = False
else:
print(language.ERR_UPDATE_CHECKER_FILE_CORRUPTED)
setUpdateChecker(True)
except:
print(language.ERR_UPDATE_CHECKER_FILE_NOT_FOUND)
setUpdateChecker(True)
loadUpdateChecker()