encrypt_password script converted to python3
This commit is contained in:
parent
1f3e165b79
commit
3ade049133
@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
key_id=salt
|
||||
|
||||
if [[ $1 != "" ]]
|
||||
then
|
||||
echo -n $1 | gpg --armor --batch --homedir="/etc/salt/gpgkeys" --trust-model always --encrypt -r "${key_id}"
|
||||
else
|
||||
echo "Please specify a password"
|
||||
fi
|
26
scripts/encrypt_password.py
Executable file
26
scripts/encrypt_password.py
Executable file
@ -0,0 +1,26 @@
|
||||
#!/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))
|
Loading…
Reference in New Issue
Block a user