mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-19 07:04:27 +01:00
Updates generate_key to accept output directory. It stores the keys in the current dir by default.
This commit is contained in:
@@ -30,14 +30,21 @@ def save_pk(pk, filename):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
name = "pisa"
|
name = "pisa"
|
||||||
|
output_dir = "."
|
||||||
|
|
||||||
opts, _ = getopt(argv[1:], "n:", ["name"])
|
opts, _ = getopt(argv[1:], "n:d:", ["name", "dir"])
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if opt in ["-n", "--name"]:
|
if opt in ["-n", "--name"]:
|
||||||
name = arg
|
name = arg
|
||||||
|
|
||||||
SK_FILE_NAME = "../{}_sk.der".format(name)
|
if opt in ["-d", "--dir"]:
|
||||||
PK_FILE_NAME = "../{}_pk.der".format(name)
|
output_dir = arg
|
||||||
|
|
||||||
|
if output_dir.endswith("/"):
|
||||||
|
output_dir = output_dir[:-1]
|
||||||
|
|
||||||
|
SK_FILE_NAME = "{}/{}_sk.der".format(output_dir, name)
|
||||||
|
PK_FILE_NAME = "{}/{}_pk.der".format(output_dir, name)
|
||||||
|
|
||||||
if os.path.exists(SK_FILE_NAME):
|
if os.path.exists(SK_FILE_NAME):
|
||||||
print('A key with name "{}" already exists. Aborting.'.format(SK_FILE_NAME))
|
print('A key with name "{}" already exists. Aborting.'.format(SK_FILE_NAME))
|
||||||
|
|||||||
Reference in New Issue
Block a user