-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencryption.py
More file actions
30 lines (23 loc) · 717 Bytes
/
encryption.py
File metadata and controls
30 lines (23 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
import pyAesCrypt
import os
from os import stat, remove
import csv
global new_name
enc_list = {}
def do_enc(item, password_enc, path):
os.chdir(path)
bufferSize = 64 * 1024
input_file = item
output_file = "{}.aes".format(item)
try:
with open(input_file, "rb") as fIn:
with open(output_file, "wb") as fOut:
pyAesCrypt.encryptStream(fIn, fOut, password_enc, bufferSize)
#get encrypted file
encFileSize = stat(output_file).st_size
new_name = "{}.{}.aes".format(input_file, encFileSize)
os.rename(output_file, new_name)
except FileNotFoundError:
pass
return new_name