def fileEraser(file_name):
    try:
        f = open(file_name, 'w')
        f.write("")
        f.close()
    except:
        logger.writeLog('Error Deleting file: ' + file_name)
def getDecText(cipher_text, log):
    global key
    cipher_suite = Fernet(key)
    plain_text = cipher_suite.decrypt(cipher_text)
    if log:
        print("\nPlain text: ", plain_text)
        logger.writeLog('getDecText: ' + plain_text.decode())
    return plain_text
def getEncText(plain_text, log):
    global key
    cipher_suite = Fernet(key)
    cipher_text = cipher_suite.encrypt(plain_text)
    cipher = binascii.hexlify(bytearray(cipher_text))
    if log:
        print(cipher_text)
        print("Cipher: ", cipher)
        print("\nVersion:\t", cipher[0:2])
        print("Time stamp:\t", cipher[2:18])
        print("IV:\t\t", cipher[18:50])
        print("HMAC:\t\t", cipher[-64:])
        logger.writeLog('getEncText: ' + cipher_text.decode())
    return cipher_text
Exemplo n.º 4
0
def check_watchdog():
    try:
        runwatchdog = int(open_config['WatchdogRun'])
        if runwatchdog > 0:
            address = open_config['WatchdogAddress']
            port = int(open_config['WatchdogPort'])
            autoRegister = int(open_config['WatchdogAutoRegister'])
            if autoRegister > 0:
                watchdogDB = fixed_config[open_config['WatchdogDB']]
                _watchdog.register(BASE_FILE.encode(), address, port,
                                   watchdogDB)
            _watchdog.start_watchdog(BASE_FILE.encode(), port)
    except:
        logger.writeLog("            ---runwatchdog--- Unexpected error: " +
                        str(sys.exc_info()[0]))
def setConfigFilePath(file_path, log):
    global configFile
    configFile = file_path
    if log:
        logger.writeLog('setConfigFilePath: ' + encryptedFile)
def getEncFilePath(log):
    global encryptedFile
    if log:
        print(encryptedFile)
        logger.writeLog('getEncFilePath: ' + encryptedFile)
    return encryptedFile
def setEncFilePath(file_path, log):
    global encryptedFile
    encryptedFile = file_path
    if log:
        logger.writeLog('setEncFilePath: ' + encryptedFile)
def getDecFilePath(log):
    global decryptedFile
    if log:
        print(decryptedFile)
        logger.writeLog('getDecFilePath: ' + decryptedFile)
    return decryptedFile
def setDecFilePath(file_path, log):
    global decryptedFile
    decryptedFile = file_path
    if log:
        logger.writeLog('setDecFilePath: ' + decryptedFile)