2020-08-29 11:40:30 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import gnupg
|
|
|
|
|
2020-09-30 00:24:02 +02:00
|
|
|
KEYID = "salt"
|
|
|
|
GPGHOME = "/etc/salt/gpgkeys"
|
2020-08-29 11:40:30 +02:00
|
|
|
|
|
|
|
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(encrypt(Password))
|