Encrypt-Decrypt any file, made without any external library.
The program takes all the bits of the file in an array, and then applies a XOR operation with a key to encrypt it. To decrypt it, it applies the XOR operation with the same key to get back the file.
Example of XOR operation and how this works
a = 10 # a represents the bits of the file you wanna encrypt
key = 27 # Any positive integer between 0 to 255
a = a ^ key #Applying XOR operation between a and the key, this encrypts the file
print(a) #a = 17
a = a ^ key #Applying XOR operation between a and the key again decrypts the file
print(a) #a = 10
-
Clone the repo in your system, head over to cryptocode.py and replace "subject.png" with name of any file you want (keep it in the same folder) in quotes.
-
Replace "encrypted_subject.png" with any name. (This will be your encrypted file)
-
Now run the code in your IDE or run in terminal/cmd:
cd File-Encrypter
python3 cryptocode.py
- In your file browser you can now see the encrypted file!
-
Open the cryptocode.py file and in the first line replace "subject.png" with the encrypted file name.
-
Replace name of your encrypted file in the 7th line to any name. (this will be your decrypted file)
-
That's it! Just run cryptocode.py and you'll see the decrypted file in your folder! 🥳
If you haven't guessed till now, DON'T USE THIS FOR ANYTHING SERIOUS, this method is super easy to crack (think of single for loop).