Skip to content

Commit

Permalink
Merge pull request #70 from WhenLifeHandsYouLemons/v1.9.2
Browse files Browse the repository at this point in the history
v1.9.2
  • Loading branch information
WhenLifeHandsYouLemons authored Apr 10, 2024
2 parents 932d229 + 25b86ac commit b681f97
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 154 deletions.
220 changes: 138 additions & 82 deletions Encryptext.pyw

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Original Files/build_number.txt

This file was deleted.

1 change: 1 addition & 0 deletions builds/build_number.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
81 changes: 28 additions & 53 deletions encryptext_installer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/python'

# Created by Sooraj S
# https://encryptext.sooraj.dev
# Free for everyone. Forever.

from os import rename, remove, rmdir, makedirs, listdir, path, environ
from shutil import rmtree
import sys
Expand Down Expand Up @@ -118,18 +122,23 @@ def progress_bar(percent_done):
update = input("\nAre you updating or installing Encryptext? [(u)pdating/(i)nstalling] ")

# Open the Encryptext.pyw file and read it into a variable
file = open(getTrueFilename("Encryptext.pyw"), "r", encoding="utf8")
file = file.read()
text = file
with open(getTrueFilename("Encryptext.pyw"), "r", encoding="utf8") as file:
text = file.read()

# Add version number to the file
file = text.split("VERSION NUMBER HERE")
text = version.join(file)

# Change debug mode to False if it's True
try:
file = text.split("debug = True")
text = "debug = False".join(file)
except: pass

# Adds computed hash to file
hash_str = "INSERT COMPUTED HASH HERE"
file = text.split("# HASH STRING HERE")
hash_line = file[1].split("'")
hash_line[1] = hash_str
file[1] = "'".join(hash_line)

text = "".join(file)
file = text.split("HASH STRING HERE")
text = hash_str.join(file)

# Communicate to old program
return_attributes = ""
Expand All @@ -143,48 +152,29 @@ def progress_bar(percent_done):
except:
raise Exception("Something went wrong! Please try again or file a crash report on GitHub.")

# Find where the encryption key is stored in the file
file = text.split("# ENCRYPTION KEY HERE")

if update == "i":
# Create a key and remove the b'' from the string
key = F.generate_key().decode()
else:
key = str(return_attributes[3].split("'")[1])

# Add the key to the file
key_line = file[1]
key_line = key_line.split("'")
key_line[1] = key
key_line = "'".join(key_line)
file[1] = key_line

text = "".join(file)
file = text.split("ENCRYPTION KEY HERE")
text = key.join(file)

print("Encryption key set!")

possible_characters = ascii_letters + digits

# Find where the format item separator string is stored in the file
file = text.split("# FORMAT ITEM SEPARATOR HERE")

if update == "i":
# Create a format item separator string
format_item_separator = "".join([choice(possible_characters) for i in range(randint(15, 45))])
else:
format_item_separator = str(return_attributes[0].split("'")[1])

# Add the format item separator string to the file
key_line = file[1]
key_line = key_line.split("'")
key_line[1] = format_item_separator
key_line = "'".join(key_line)
file[1] = key_line

text = "".join(file)

# Find where the format separator string is stored in the file
file = text.split("# FORMAT SEPARATOR HERE")
file = text.split("FORMAT ITEM SEPARATOR HERE")
text = format_item_separator.join(file)

if update == "i":
# Create a format separator string
Expand All @@ -193,16 +183,8 @@ def progress_bar(percent_done):
format_separator = str(return_attributes[1].split("'")[1])

# Add the format separator string to the file
key_line = file[1]
key_line = key_line.split("'")
key_line[1] = format_separator
key_line = "'".join(key_line)
file[1] = key_line

text = "".join(file)

# Find where the format string is stored in the file
file = text.split("# FORMAT STRING HERE")
file = text.split("FORMAT SEPARATOR HERE")
text = format_separator.join(file)

if update == "i":
# Create a format string
Expand All @@ -211,13 +193,8 @@ def progress_bar(percent_done):
format_string = str(return_attributes[2].split("'")[1])

# Add the format string to the file
key_line = file[1]
key_line = key_line.split("'")
key_line[1] = format_string
key_line = "'".join(key_line)
file[1] = key_line

text = "".join(file)
file = text.split("FORMAT STRING HERE")
text = format_string.join(file)

print("Format strings set!")

Expand All @@ -231,7 +208,6 @@ def progress_bar(percent_done):
keep_settings = input("\nDo you want to load your settings from an old version?\nNOTE: If you don't have an older version, it will create new settings by default [(y)es/(n)o] ")

data = {
"version": version,
"recentFilePaths": [],
"maxRecentFiles": 5,
"otherSettings": {
Expand All @@ -256,7 +232,6 @@ def progress_bar(percent_done):
file = json.load(file)

data = {
"version": version,
"recentFilePaths": file["recentFilePaths"],
"maxRecentFiles": file["maxRecentFiles"],
"otherSettings": {
Expand Down Expand Up @@ -318,7 +293,7 @@ def progress_bar(percent_done):
# Moves the exe out of the dist folder
rename(path.join(dir_path, "dist", "encryptext.exe"), path.join(dir_path, f"encryptext_v{version}.exe"))

# Create desktop shortcut
# Create desktop shortcut for Windows
# https://stackoverflow.com/a/69597224
try:
from win32com.client import Dispatch
Expand All @@ -333,7 +308,7 @@ def progress_bar(percent_done):
except:
print(f"Couldn't create Desktop shortcut!")

# Create Start Menu shortcut
# Create Start Menu shortcut for Windows
try:
# Create Start Menu folder for Encryptext
makedirs(path.join(home_dir, "AppData", "Roaming", "Microsoft", "Windows", "Start Menu", "Programs", "Encryptext"), exist_ok=True)
Expand Down
31 changes: 13 additions & 18 deletions installer_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import hashlib
import PyInstaller.__main__

version = "1.9.1"
version = "1.9.2"
testing = False

def update_build_number():
with open("Original Files/build_number.txt", "r") as file:
with open("builds/build_number.txt", "r") as file:
build_number = int(file.read().strip())
build_number += 1
with open("Original Files/build_number.txt", "w") as file:
with open("builds/build_number.txt", "w") as file:
file.write(str(build_number))
return build_number

Expand All @@ -27,30 +27,25 @@ def computeHash(input_string: str) -> str:
return hash_object.hexdigest()

def modifyInstallerFile(add: bool) -> None:
if add:
# Add the computed hash and version number
with open("encryptext_installer.py", "r+") as file:
installer_file = file.read()
with open("encryptext_installer.py", "r+") as file:
installer_file = file.read()

if add:
# Add the computed hash and version number
installer_parts = installer_file.split("INSERT COMPUTED HASH HERE")
installer_file = hash_str.join(installer_parts)
installer_parts = installer_file.split("INSERT VERSION NUMBER HERE")
installer_file = version.join(installer_parts)

file.seek(0)
file.write(installer_file)
file.truncate()
else:
# Remove the computed hash and version number
with open("encryptext_installer.py", "r+") as file:
installer_file = file.read()
else:
# Remove the computed hash and version number
installer_parts = installer_file.split(hash_str)
installer_file = "INSERT COMPUTED HASH HERE".join(installer_parts)
installer_parts = installer_file.split(version)
installer_file = "INSERT VERSION NUMBER HERE".join(installer_parts)

file.seek(0)
file.write(installer_file)
file.truncate()
file.seek(0)
file.write(installer_file)
file.truncate()

# Open the key.txt file and read in the key
with open("Original Files/key.txt", "r") as file:
Expand Down

0 comments on commit b681f97

Please sign in to comment.