Skip to content

Commit c77ee9e

Browse files
Merge pull request #2874 from Kalivarapubindusree/soft
Folder Locker and Hider script added
2 parents 84517d2 + e81765a commit c77ee9e

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import os
2+
3+
def xor_encrypt_decrypt(data, key):
4+
return bytes([byte ^ key for byte in data])
5+
6+
def lock_file(file_path, key):
7+
try:
8+
with open(file_path, 'rb') as file:
9+
data = file.read()
10+
11+
encrypted_data = xor_encrypt_decrypt(data, key)
12+
13+
with open(file_path, 'wb') as file:
14+
file.write(encrypted_data)
15+
16+
except Exception as e:
17+
print(f'Error locking the file: {e}')
18+
19+
def hide_file(file_path):
20+
try:
21+
os.rename(file_path, '.' + file_path)
22+
except Exception as e:
23+
print(f'Error hiding the file: {e}')
24+
25+
def lock_and_hide_folder(folder_path, key):
26+
try:
27+
for root, dirs, files in os.walk(folder_path):
28+
for file in files:
29+
file_path = os.path.join(root, file)
30+
lock_file(file_path, key)
31+
hide_file(file_path + '.locked')
32+
33+
os.rename(folder_path, '.' + folder_path)
34+
print(f'Folder locked and hidden as .{folder_path}')
35+
36+
except Exception as e:
37+
print(f'Error locking and hiding the folder: {e}')
38+
39+
def main():
40+
folder_path = input("Enter the folder path: ")
41+
key = int(input("Enter the encryption key (an integer): "))
42+
43+
lock_and_hide_folder(folder_path, key)
44+
45+
if __name__ == "__main__":
46+
main()

Folder_locker_and_Hider/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Folder_Locker_And_Hider
2+
3+
Short description of package/script
4+
5+
- This Script Was simple to setup
6+
- Need import os
7+
8+
## Setup instructions
9+
10+
Just Need to Import os then run the Folder_Locker_And_Hider.py file and for running python3 is must be installed!
11+
12+
## Detailed explanation of script, if needed
13+
14+
This Script Is Only for Folder_Locker_And_Hider use only!

0 commit comments

Comments
 (0)