forked from tecnico-sec/Python-Crypto-Details
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFileMixer.py
More file actions
30 lines (21 loc) · 843 Bytes
/
Copy pathFileMixer.py
File metadata and controls
30 lines (21 loc) · 843 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
class FileMixer:
def mix2(file1Path, file2Path, outputFilePath, manipulationFunction):
with open(file1Path, 'rb') as f:
file1 = f.read()
with open(file2Path, 'rb') as f:
file2 = f.read()
outputBytes = manipulationFunction.mix(file1, file2)
writemode = "wb"
if isinstance(outputBytes, str):
writemode="w"
with open(outputFilePath, writemode) as f:
f.write(outputBytes)
def mix1(filePath, outputFilePath, manipulationFunction):
with open(filePath, 'rb') as f:
file = f.read()
outputBytes = manipulationFunction.mix(file, None)
writemode = "wb"
if isinstance(outputBytes, str):
writemode = "w"
with open(outputFilePath, writemode) as f:
f.write(outputBytes)