1
0
Fork 0
mirror of https://github.com/ThomasGsp/HyperProxmox.git synced 2025-03-09 15:40:18 +00:00

Change Json format - standard

This commit is contained in:
Tlams 2018-03-22 15:33:37 +00:00
parent 724b5c0f72
commit 2f335cf27a

View file

@ -46,7 +46,7 @@ class CryticalData:
key_generation = { key_generation = {
"result": "ERROR", "result": "ERROR",
"type": "PYTHON", "type": "PYTHON",
"Error": "Key generation fail: {0}".format(e) "value": "Key generation fail: {0}".format(e)
} }
return key_generation return key_generation
@ -58,13 +58,13 @@ class CryticalData:
file_key_pub.close() file_key_pub.close()
result_public_key = { result_public_key = {
"result": "OK", "result": "OK",
"data": self.public_key "value": self.public_key
} }
except BaseException as e: except BaseException as e:
result_public_key = { result_public_key = {
"result": "ERROR", "result": "ERROR",
"type": "PYTHON", "type": "PYTHON",
"error": "Your public key seem to invalid: {0}".format(e) "value": "Your public key seem to invalid: {0}".format(e)
} }
return result_public_key return result_public_key
@ -75,14 +75,14 @@ class CryticalData:
file_key_pvt.close() file_key_pvt.close()
result_private_key = { result_private_key = {
"result": "OK", "result": "OK",
"data": self.private_key "value": self.private_key
} }
except BaseException as e: except BaseException as e:
result_private_key = { result_private_key = {
"result": "ERROR", "result": "ERROR",
"type": "PYTHON", "type": "PYTHON",
"error": "Your private key seem to invalid: {0}".format(e) "value": "Your private key seem to invalid: {0}".format(e)
} }
return result_private_key return result_private_key
@ -92,18 +92,18 @@ class CryticalData:
if key: if key:
result_encrypt = { result_encrypt = {
"result": "OK", "result": "OK",
"data": encfrypt[0] "value": encfrypt[0]
} }
else: else:
result_encrypt = { result_encrypt = {
"result": "OK", "result": "OK",
"data": self.public_key.encrypt(data.encode("utf-8"), 64) "value": self.public_key.encrypt(data.encode("utf-8"), 64)
} }
except BaseException as e: except BaseException as e:
result_encrypt = { result_encrypt = {
"result": "ERROR", "result": "ERROR",
"type": "PYTHON", "type": "PYTHON",
"error": "Data encryption failed: {0}".format(e) "value": "Data encryption failed: {0}".format(e)
} }
return result_encrypt return result_encrypt
@ -112,17 +112,20 @@ class CryticalData:
if key: if key:
result_decryption = { result_decryption = {
"result": "OK", "result": "OK",
"data": key.decrypt(data) "type": "PYTHON",
"value": key.decrypt(data)
} }
else: else:
result_decryption = { result_decryption = {
"result": "OK", "result": "OK",
"data": self.private_key.decrypt(data) "type": "PYTHON",
"value": self.private_key.decrypt(data)
} }
except BaseException as e: except BaseException as e:
result_decryption = { result_decryption = {
"result": "ERROR", "result": "ERROR",
"type": "PYTHON", "type": "PYTHON",
"error": "Data decryption failed: {0}".format(e) "value": "Data decryption failed: {0}".format(e)
} }
logger.write({"result": "INFO", "type": "PYTHON", "value": "Create locker file"})
return result_decryption return result_decryption