sio-2425/delivery1/client/bin/rep_subject_credentials

42 lines
905 B
Plaintext
Raw Normal View History

2024-11-12 10:26:56 +00:00
#!/bin/python3
import sys
import logging
import argparse
from cryptLib import keyPair
2024-11-12 10:26:56 +00:00
logging.basicConfig(format='%(levelname)s\t- %(message)s')
logger = logging.getLogger()
logger.setLevel(logging.INFO)
# Generate a key pair for a subject
# password - file for keys
def generateKeyPair(args):
parser = argparse.ArgumentParser()
parser.add_argument('password', nargs='?', default=None)
parser.add_argument('file', nargs='?', default=None)
args = parser.parse_args()
if len(args) != 2:
2024-11-12 10:26:56 +00:00
logger.error("Need password and file to store keys")
sys.exit(-1)
#Generate the key pair
keys = keyPair.generate_key_pair(args.password)
2024-11-12 10:26:56 +00:00
#Get the 2 different keys
pubKey = ''
privateKey = ''
with open(args.file, "wb") as f:
2024-11-12 10:26:56 +00:00
f.write(pubKey.encode() + b"\n\n" + privateKey.encode())
if __name__ == '__main__':
generateKeyPair(sys.argv)