Aug-25-2018, 05:07 PM
(This post was last modified: Aug-25-2018, 05:07 PM by ahmed_mokhles.)
When I changed the base to console and tried again, the EXE gives the exact same error except now it shows in in the EXE console and not as a popup as it used to.
But you know what? I think this will never be solved until I REALLY tell you guys what I'm making.
I want to make a text encrypter, which when text is input, it encrypts it with the algorithm I made and creates another .py script that decrypts the text. But so no one can read the letter codes created I want the program to be in EXE form, but that will create a .py script which I also want in EXE form. So what I want to do is create an EXE out of the main program with pyinstaller, then I want that to create the decryption program and then compile it so that both are EXEs. Here is what I have till now:
PyEncrypt 2.0.py:
Take the code, test it out on your PC and try to see what's wrong plz.
Thanks.
But you know what? I think this will never be solved until I REALLY tell you guys what I'm making.
I want to make a text encrypter, which when text is input, it encrypts it with the algorithm I made and creates another .py script that decrypts the text. But so no one can read the letter codes created I want the program to be in EXE form, but that will create a .py script which I also want in EXE form. So what I want to do is create an EXE out of the main program with pyinstaller, then I want that to create the decryption program and then compile it so that both are EXEs. Here is what I have till now:
PyEncrypt 2.0.py:
import os import random import time logo = "\n ======================= PyEncrypt 2.0 ========================\n" def initialize(): os.system('title PyEncrypt 2.0') os.system('cls') os.system('color 0a') os.system('mode con: cols=64 lines=16') chars = str("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890-_',.:;+=()!@#$%^&*|/\\~`?><[]}{") global data data = {} for i in chars: data[i] = random.randint(1000000000, 10000000000) def enterData(): os.system('cls') print(logo) global filename filename = str(input("\n Enter a name for the output file:\n\n >>> ")) os.system('cls') print(logo) global password password = str(input("\n Enter a password to protect your encrypted text:\n\n >>> ")) os.system('cls') print(logo) textToEncrypt = str(input("\n Now enter the text you wish to encrypt:\n\n >>> ")) OUTPUT = open(filename + ".txt", "w+") for i in range(len(textToEncrypt)): getValue = str(textToEncrypt[i]) OUTPUT.write(str(data[getValue]) + "\n") def createEncrypterProgram(): DECRYPTER = open(filename + ".decrypt.py", "w+") DECRYPTER.write(""" import os import time os.system('title PyEncrypt 2.0 - Decrypt """ + '"' + filename + ".txt" + '"' + """') os.system('cls') os.system('color 0a') os.system('mode con: cols=64 lines=16') password = """ + '"' + password + '"' + """ filename = """ + '"' + filename + '"' + """ if os.path.isfile("./" + filename + ".txt"): os.system('cls') else: os.system('cls') print(" ") print(" No file with encrypted text found!") time.sleep(0.5) exit() os.system('cls') print(" ") print(" Enter the password that you used to encrypt your text:") print(" ") passwordCheck = str(input(" >>> ")) os.system('cls') if password == passwordCheck: os.system('cls') else: os.system('cls') print(" ") print(" Incorrect Password!") time.sleep(0.5) exit() data = """ + str(data) + """ data2 = {val:key for (key, val) in data.items()} INPUT = open(filename + ".txt", "r") OUTPUT2 = open(filename + ".decrypted.txt", "w+") for line in INPUT: OUTPUT2.write(str(data2[int(line)])) os.system('cls') print(" ") print(" Decryption complete!") time.sleep(0.5) """) DECRYPTER.close() def createCompiler(): compiler = open("compiler.py", "w+") compiler.write(""" import sys from cx_Freeze import setup, Executable base = None if sys.platform == "win32": base = "Console" buildOptions = dict( packages = [ 'os', 'time'], excludes = []) executables = [ Executable( str(""" + '"' + "D:/Python/PyEncrypt 2.0/" + filename + '"' + """ + ".decrypt.py"), base = base,)] setup( name='Decrypt', version = '2.0', description = 'Decrypt', options = dict(build_exe = buildOptions), executables = executables) """) compiler.close() initialize() enterData() createEncrypterProgram() createCompiler() os.system('python compiler.py build') os.system('del compiler.py') os.system('cls') print(logo) print("\n Encryption complete!") time.sleep(0.5)This encrypts, creates a decrypter and compiles it. However my problems are with the compiled EXE. Notice that this code creates a decrypter and then creates a compiler (the setup.py) and then runs it. The compiler should compile the decrypter. Plz help me with this and ask for any info you need. Note that this code only works on Windows!
Take the code, test it out on your PC and try to see what's wrong plz.
Thanks.