#!/usr/bin/python3 import argparse import gnupg KEYID="salt" GPGHOME="/etc/salt/gpgkeys" def parse_args(): parser = argparse.ArgumentParser(description='Encrypt password') parser.add_argument('password', type=str, nargs=1, help='password to encrypt') args = parser.parse_args() return args def encrypt(password=""): gpg = gnupg.GPG(gnupghome=GPGHOME, secret_keyring=KEYID) encrypted_password = gpg.encrypt(password, KEYID) return encrypted_password if __name__ == "__main__": Args = parse_args() Password = Args.password[0] print(f"Encrypting password {Password}") print(encrypt(Password))