Beispiel #1
0
def checksumDatabase(database, mode: str):
    objet_mode, index = get_object_mode(database)
    if objet_mode is None: return None
    mode_db = objet_mode.get_mode()
    # sha256 -> 1
    if mode.lower().strip() == "sha256":
        data = ""
        if mode_db.lower().strip() == "avl":
            data = avl.showTables(database)
        elif mode_db.lower().strip() == "b":
            data = list()
            for tables in b.showTables(database):
                data.append(b.extractTable(database, tables))
        elif mode_db.lower().strip() == "bPlus".lower():
            data = bPlus.showTables(database)
        elif mode_db.lower().strip() == "dict":
            data = diccionario.showTables(database)
        elif mode_db.lower().strip() == "hash":
            data = hash.showTables(database)
        elif mode_db.lower().strip() == "isam":
            data = isam.showTables(database)
        elif mode_db.lower().strip() == "json":
            data = json.showTables(database)
        return checksum_database(1, database, mode_db, data)
    # md5 -> 2
    elif mode.lower().strip() == "md5":
        data = ""
        if mode_db.lower().strip() == "avl":
            data = avl.showTables(database)
        elif mode_db.lower().strip() == "b":
            data = list()
            for tables in b.showTables(database):
                data.append(b.extractTable(database, tables))

        elif mode_db.lower().strip() == "bPlus".lower():
            data = bPlus.showTables(database)
        elif mode_db.lower().strip() == "dict":
            data = diccionario.showTables(database)
        elif mode_db.lower().strip() == "hash":
            data = hash.showTables(database)
        elif mode_db.lower().strip() == "isam":
            data = isam.showTables(database)
        elif mode_db.lower().strip() == "json":
            data = json.showTables(database)
        return checksum_database(2, database, mode_db, data)
    else:
        return None
Beispiel #2
0
def checksumDatabase(database, mode: str):
    objet_mode, index = get_metadata_db(database)
    if objet_mode is None: return None
    mode_db = objet_mode.get_mode()
    struct = get_struct(mode_db)
    # sha256 -> 1
    # md5 -> 2
    if mode.lower().strip() == "sha256" or mode.lower().strip() == "md5":
        data = ""
        if mode_db != "b":
            data = struct.showTables(database)
        else:
            data = list()
            for tables in struct.showTables(database):
                data.append(struct.extractTable(database, tables))

        return checksum_database(1 if mode.lower().strip() == "sha256" else 2, database, mode_db, data)
    else:
        return None