Some of the older, easier and no more secure ciphers are substitution ciphers. So instead, I looked into ways of encrypting the code with symmetric encryption. Since I want to encrypt a rather large text, I didn’t think asymmetric encryption would make a lot of sense. write ( encoded )įinally, I wanted to look at some easy encryption options. decode ( "utf-8" ) with open ( path, 'w' ) as f : f. b64encode ( bytes ( data, "utf-8" )) encoded = encoded. Import base64 def base64_encode (): with open ( path, 'r' ) as f : data = f. I want to open the file in write mode (‘w’), because I want the already existing data to be overwritten.construction, I do not need to worry about closing the file later. Knowing which file to write to, I next use the integrated Python function to open and write to the file. (If you have worked with Python before, you might have seen this: _name_ = '_main_'.) One of these attributes is _file_, which is the variable that contains the pathname of the file. path = _file_ - Python offers some special attributes and functions.The very first argument will be the name of the script. These arguments are a list that can be accessed with sys.argv. path = sys.argv - When writing a command-line tool you can add arguments right when executing the script.
![code zero zero zero destruct zero code zero zero zero destruct zero](https://i.ebayimg.com/images/g/OqkAAOSw8pFfqpdv/s-l300.jpg)
Instead of statically adding a string in the code, I wanted to make it work, even if the name of the file would be changed. To be able to do this, the first step was to get the correct filename. The goal was to write a short function that would override the existing code.
![code zero zero zero destruct zero code zero zero zero destruct zero](https://i1.wp.com/http2.mlstatic.com/tarjeta-rixty-game-card-u5-roblox-y-muchos-jueg!%20%20%20os-online-D_NQ_NP_622667-MLA27317963701_052018-F.jpg)
The idea for this project started with creating a self-destructing code. I sat down for an afternoon and this project was created. Additionally, I got the idea to combine this with learning more about encoding and encrypting data in Python. So once it runs, the file would be overwritten or gone. I wanted to practice some more Python and my idea was self-destructing code. This project is a little smaller, perfect for an afternoon. My last project was a weekend project where I brushed up my Python, Web Mining and Natural Language Processing skills. I am always thinking about some new, fun projects, which are possible in the afternoon or on a weekend.