|
@@ -1,5 +1,5 @@
|
|
import argparse
|
|
import argparse
|
|
-from os.path import join, exists, isfile
|
|
|
|
|
|
+from os.path import join, exists, isfile, basename
|
|
from os import makedirs, listdir
|
|
from os import makedirs, listdir
|
|
|
|
|
|
from core import shamir_decode, shamir_encode
|
|
from core import shamir_decode, shamir_encode
|
|
@@ -32,8 +32,10 @@ def main():
|
|
args = parser.parse_args()
|
|
args = parser.parse_args()
|
|
|
|
|
|
if args.mode == 'split':
|
|
if args.mode == 'split':
|
|
|
|
+ name = basename(args.file)
|
|
|
|
+
|
|
for part_id in range(args.n):
|
|
for part_id in range(args.n):
|
|
- name_file = f'{args.file}.{part_id+1}.shamir'
|
|
|
|
|
|
+ name_file = f'{name}.{part_id+1}.shamir'
|
|
path = join(args.output, name_file)
|
|
path = join(args.output, name_file)
|
|
if exists(path):
|
|
if exists(path):
|
|
print(f"File: {path} already exists, use another directory.")
|
|
print(f"File: {path} already exists, use another directory.")
|
|
@@ -47,7 +49,7 @@ def main():
|
|
parts = shamir_encode(data, args.k, args.n)
|
|
parts = shamir_encode(data, args.k, args.n)
|
|
|
|
|
|
for part_id, part in enumerate(parts):
|
|
for part_id, part in enumerate(parts):
|
|
- name_file = f'{args.file}.{part_id+1}.shamir'
|
|
|
|
|
|
+ name_file = f'{name}.{part_id+1}.shamir'
|
|
path = join(args.output, name_file)
|
|
path = join(args.output, name_file)
|
|
with open(path, 'wb') as f:
|
|
with open(path, 'wb') as f:
|
|
f.write(part)
|
|
f.write(part)
|