removed client from options for functions as it is a global variable
This commit is contained in:
@@ -60,7 +60,7 @@ def write_config_file(array, config_file):
|
|||||||
logger.debug("Converting config from array to json")
|
logger.debug("Converting config from array to json")
|
||||||
array_json = json.dumps(array)
|
array_json = json.dumps(array)
|
||||||
logger.debug("Encrypting config json")
|
logger.debug("Encrypting config json")
|
||||||
encrypted_array_json = encrypt(client, array_json)
|
encrypted_array_json = encrypt(array_json)
|
||||||
logger.debug("Attempting to write encrypted config to file")
|
logger.debug("Attempting to write encrypted config to file")
|
||||||
try:
|
try:
|
||||||
f = open(config_file, "w")
|
f = open(config_file, "w")
|
||||||
@@ -84,7 +84,7 @@ def read_config_file(config_file):
|
|||||||
logger.error("Unable to read encrypted config from file. Error: {}".format(e))
|
logger.error("Unable to read encrypted config from file. Error: {}".format(e))
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
logger.debug("Decrypting config contents")
|
logger.debug("Decrypting config contents")
|
||||||
decrypted_array_json = decrypt(client, config)
|
decrypted_array_json = decrypt(config)
|
||||||
logger.debug("Convert config from json to array")
|
logger.debug("Convert config from json to array")
|
||||||
array = json.loads(decrypted_array_json)
|
array = json.loads(decrypted_array_json)
|
||||||
logger.debug("Finished reading config file and decrypting contents")
|
logger.debug("Finished reading config file and decrypting contents")
|
||||||
@@ -104,7 +104,7 @@ def ask_for_confirmation(question):
|
|||||||
else:
|
else:
|
||||||
print("This value must be one of the following characters: y, n.")
|
print("This value must be one of the following characters: y, n.")
|
||||||
|
|
||||||
def create_encryption_key(client):
|
def create_encryption_key():
|
||||||
# Create an encryption key.
|
# Create an encryption key.
|
||||||
try:
|
try:
|
||||||
key_id = client.create(
|
key_id = client.create(
|
||||||
@@ -130,7 +130,7 @@ def create_encryption_key(client):
|
|||||||
logger.error(e)
|
logger.error(e)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
def create_hmac_key(client):
|
def create_hmac_key():
|
||||||
# Create an encryption key.
|
# Create an encryption key.
|
||||||
try:
|
try:
|
||||||
key_id = client.create(
|
key_id = client.create(
|
||||||
@@ -156,7 +156,7 @@ def create_hmac_key(client):
|
|||||||
logger.error(e)
|
logger.error(e)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
def encrypt(client, data):
|
def encrypt(data):
|
||||||
try:
|
try:
|
||||||
data = data.encode('UTF-8')
|
data = data.encode('UTF-8')
|
||||||
key_id = create_encryption_key(client)
|
key_id = create_encryption_key(client)
|
||||||
@@ -194,7 +194,7 @@ def encrypt(client, data):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
|
|
||||||
def decrypt(client, data):
|
def decrypt(data):
|
||||||
array_json = base64.b64decode(data)
|
array_json = base64.b64decode(data)
|
||||||
array = json.loads(array_json)
|
array = json.loads(array_json)
|
||||||
if array['version'] == 1:
|
if array['version'] == 1:
|
||||||
@@ -203,7 +203,7 @@ def decrypt(client, data):
|
|||||||
logger.error("Unable to detemine encryption version.")
|
logger.error("Unable to detemine encryption version.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def decrypt_v1(client, array):
|
def decrypt_v1(array):
|
||||||
try:
|
try:
|
||||||
logger.debug("Dict of info: {}".format(array))
|
logger.debug("Dict of info: {}".format(array))
|
||||||
key_id = array['cipher_key_id']
|
key_id = array['cipher_key_id']
|
||||||
|
|||||||
Reference in New Issue
Block a user